Zagstrug
Zagstrug

Reputation: 1729

Twilio: Finding the SID of a call or a conference

I am having trouble find the SID of a call or a conference once it is created.

I need these parameters, in order to modify a live call, or kick a participant from the conference.

Starting with a basic example (I'm coding in Ruby) :

//Paramaters\

require 'twilio-ruby'

account_sid = '//myaccount#'

auth_token = '//myauthtoken'

Creating the call :

@client = Twilio::REST::CLient.new account_sid, auth_token

call = @client.account.calls.create({:from => '//outgoing#', :to => '//incoming#', :method => 'get'})

puts call.sid

Then the hangup part :

@hangup = @client.account.calls.get("CallSid")

@call.update(:status => 'completed')

puts @call.direction

So as you can see, to execute the second part (hangup), I need to have the Sid of the call that was just created in order to modify it later (either redirect it, put it in a conference, or hang it up.)

Upvotes: 2

Views: 1403

Answers (2)

coolaj86
coolaj86

Reputation: 77084

Just for the non-ruby peeps that fall into this later:

You want the REST (not TwiML) docs.

Specifically for Conference http://www.twilio.com/docs/api/rest/conference

And also Participants: http://www.twilio.com/docs/api/rest/participant

And you might as well check out Modifying Live Calls while your at it: http://www.twilio.com/docs/api/rest/change-call-state

Upvotes: 1

Dylan Markow
Dylan Markow

Reputation: 124439

puts call.sid should be outputting the SID to the console.

If you need to use it later, you can assign it to a variable instead:

@sid = call.sid

@hangup = @client.account.calls.get(@sid)

Upvotes: 2

Related Questions