我正试图在我的Rails控制器中使用以下GET请求获取Twilio录音到他们的API:
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
结果我收到500响应错误消息“Authenticate”
我的申请追踪是 app / controllers / campaigns_controller.rb:13:在'myrecordings'[@recordings line]
据我所知,我正在关注Twilio文档中的内容:
http://www.twilio.com/docs/api/rest/recording
但显然我错过了一些东西。 account_sid和auth_token是正确的,但存在安全问题吗?
答案 0 :(得分:1)
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
从文档中,这也应该有效,假设您将sid和令牌更改为正确的