addDial and addNumber details

48 views
Skip to first unread message

Dhairya Vora

unread,
Nov 11, 2011, 12:20:21 AM11/11/11
to plivo...@googlegroups.com
Hi group,
Scenario is :
  • User1 has called the system.
  • System has to connect User1 to User2.
  • If User2 does not pickup the call in 30 seconds (or User2 rejects the call), User1 should be redirected  to some other URL (URL1).
    • (optional) If User2 accepts the call, after the talk ends (i.e. User2 disconnects the call), User1 should be redirected to some URL (URL2).
Here is what I have tried:
$d = $r->addDial(array(
                        'action' => $server_path."/afterCallEnds.php",
                        'dialMusic' => $server_path."/holdMusic.php",
                        'timeout' => 30,
                        'callerId' => $user1Number,
                        'callbackUrl' => $server_path."/user2PickUp.php",
                        ));

$d->addNumber($user2Number,array('gateways' => $gatewayValue,));

But this does not work.
  • After 30 seconds, User1 is still listening the holdMusic
  • If User2 rejects the call, User1 is still listening the holdMusic
  • After the talk, if User2 ends the call, User1 is also disconnected.
Any help??

-Dhairya

Dhairya Vora

unread,
Nov 11, 2011, 4:26:44 AM11/11/11
to plivo...@googlegroups.com
solved myself.
only issue remaining is plivo retries to call User2 when User2 disconnects the call.

-thanks

MoroSwitie

unread,
Nov 11, 2011, 6:29:05 AM11/11/11
to plivo...@googlegroups.com
Could you also supply your fix, just in case somebody else encounters
the same problem.

Dhairya Vora

unread,
Nov 14, 2011, 4:36:10 AM11/14/11
to plivo...@googlegroups.com
ya sure. I will put what i have tried. Actually documentation at http://www.plivo.org/docs/restxml/voice-elements/dial/ was not clear. So, i will put my code as an example.
'timeout' parameter did not work as which it was expected. 'actionURL' was called twice instead of once.

So, Here are the details:

connectTwoUsers.php
$d = $r->addDial(array(
'action' => $server_path."/afterCallEnds.php",
'dialMusic' => $server_path."/holdMusic.php",
'timeout' => 10,
'callerId' => "$User1PhoneNumber",
'redirect' => 'true',
'callbackUrl' => $server_path."/user2PickUp.php",
));
--------------------------------------------------------------------------------------
afterCallEnds.php
if($_REQUEST['DialBLegUUID']=='')
{
/*user2 rejected the call OR did not answer the call*/
$r->addSpeak("Could not connect to user2. Please try after some time.");
$r->addRedirect($server_path."/url1.php");
}
else
{ //talk between user1 and user2 was successfully ended.
$r->addRedirect($server_path."/url2.php");
}
----------------------------------------------------------------------------------------
User2PickUp.php : 
1. If User2 picks up the phone, this page is called twice 
i. when user2 Picks up the phone
ii. when user1 Or User2 hangs up the phone
2. If User2 does not receive the call at all, this page will not be callled.

if(strcasecmp($_REQUEST['DialBLegStatus'],"hangup")!=0)
{ //pick up
mysql_query($insertQuery);
}
else
{ //hangup
mysql_query($update_query);
}

Hope this helps...
 -Dhairya

Mike

unread,
Nov 14, 2011, 4:51:23 AM11/14/11
to plivo...@googlegroups.com
Hi,

paste your plivo logs + FS logs + REST XML (not php code, the
generated xml) related to this call so I will check .

Mike

--

Mike

Reply all
Reply to author
Forward
0 new messages