1
votes

I'm trying to grab Twilio recordings with the following GET request to their API in my Rails controller:

def myrecordings
    account_sid = 'AC32a3c49700934481addd5ce1659f04d2'
    auth_token = 'asd89f677asd897asdfd9' #this is made up for now
    client = Twilio::REST::Client.new(account_sid, auth_token)
    @recordings = client.account.recordings.list() 
    render :json => @recordings
end

As a result I'm getting a 500 response error with the message "Authenticate"

My application trace is
app/controllers/campaigns_controller.rb:13:in `myrecordings' [the @recordings line]

To the best of my knowledge I'm following what are in the Twilio docs here:
http://www.twilio.com/docs/api/rest/recording

But clearly I'm missing something. The account_sid and auth_token are correct, but is there a security issue?

1
What's the error say? line 13, but is it a nil? or not enough args? - pjammer

1 Answers

1
votes
require 'rubygems'
require 'twilio-ruby' # Download twilio-ruby from twilio.com/docs/libraries
# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'AC32a3c49700934481addd5ce1659f04d2'
auth_token = '{{ auth_token }}'
@client = Twilio::REST::Client.new account_sid, auth_token
# Loop over recordings and print out a property for each one
@client.account.recordings.list.each do |recording|
  puts recording.sid
end  

From the docs, this should work too, assuming you change the sid and token to the right ones