0
votes

I need to modify current in-progress call. if A calls B, they are connected and have a talk, I need to redirect B to some Twiml URL, and to disconnect A from call (I can do this via JavaScript SDK .diconnect() function, since I am the "A" caller). I am using an example from Twilio docs (php SDK v4.x):

$call = $client->account->calls->get($callsid);
$call->update(array(
    "Url" => "http://path-to-twiml.php",
    "Method" => "POST"
)); 

but nothing happens. Is it possible to somehow do what I need without using Conference Twilio options?

PS: adding "Status" => "complete" parameter to update options causes disconnect for both sides of a call, since I need to disconnect only 1 (the one who initiated the call) and to leave other (redirected to specific twiml url)

1
How are you passing the call Sid to that function?philnash
when I create a call by JavaScript SDK, i catch it: Twilio.Device.connect(function (conn) { callsid = conn.parameters.CallSid; }); and then send it to php through ajax.Yuri Shmelev

1 Answers

1
votes

Twilio evangelist here.

From the code that you posted, I'm guessing that the callsid you are modifying is actually Caller A, not Caller B. In your scenario, A and B are each going to have their own seperate callsid, where Caller A is the "parent" and Caller B is the "child".

To get the child sid, you can include a URL in the statusCallback parameter in your <Dial> verb which will get requested when Caller B answers. The callsid parameter of this request is Caller B's sid. You'll also receive a parameter named parentCallSid which is Caller A's sid and that lets you correlate the child leg (Caller B) with the parent leg (Caller A).

Once you have child sid, you can modify it using the PHP library.

Hope that helps.