0
<?php 
#Link to developer portal  for connect to agent https://developer.exotel.com/api/#call-agent
$post_data = array(
'From'     => "from_number",
'To'       => "to_number",
'Url'      => "http://my.exotel.com/Exotel/exoml/start_voice/0000000000",
'CallerId' => "000",
'CallType' => "trans" 
); 
$api_key     = "api_key"; 
$api_token   = "api_token"; 
$exotel_sid  = "sid";
#Replace <subdomain> with the region of your account
#<subdomain> of Singapore cluster is @api.exotel.com
#<subdomain> of Mumbai cluster is @api.in.exotel.com 
$url = "https://" . $api_key .  ":"  . $api_token . "@api.exotel.com/v1/Accounts/" .     $exotel_sid . "/Calls/connect"; 
$ch  = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
$http_result = curl_exec($ch);
curl_close($ch);
echo "<pre>";
print "Response = ".print_r($http_result);
?>

HI, Take a look This is my curl code for connecting two mobiles through exotel server. I am getting call to 'From' number. After picked up the call it says the number is not properly setup and asking to use app bazaar. But I linked my number in app bazaar eventhough i am getting this note. Can anyone help me out, where i am wrong?

Hira
  • 293
  • 4
  • 19
  • Can you try putting your exophone as caller ID? – Abhicoding Jun 26 '20 at 22:47
  • I have added image, please take a look, in that image i am using the second one as my callerID – Hira Jun 27 '20 at 04:47
  • Hi, I think you have two things mixed up here. If you are trying to connect two numbers then you need to give From, To and CallerId. If you are trying to connect the number to a flow, then you have to give Url INSTEAD of To number. From the screen shot we cannot determine if the flow is configured correctly. It would be great if you could share the response of the API. On side note: hello@exotel.com would be the best forum for resolution of your issues. – Abhicoding Jun 27 '20 at 08:57

2 Answers2

0

In case you want to make call between two number, you just need to pass From, To and CallerId in post data (no need to pass URL as it is to connect customer to a call flow) and make sure you pass CallerId as 04448137003 i.e without - in numbers.

0

This (it says the number is not properly set up) error message comes when you are giving To and URL both the parameters in one request. In your case, you are trying to make a connect customer to a flow call. Please comment To.

<?php 
#Link to developer portal  for connecting to agent https://developer.exotel.com/api/#call-agent
$api_key     = "api_key"; 
$api_token   = "api_token"; 
$exotel_sid  = "sid";
$flow_id = "flow_id"; //FlowId will be available in the app bazaar page. Eg: 261787.
$post_data = array(
'From'     => "from_number",
'Url'      => "http://my.exotel.com/".$exotel_sid."/exoml/start_voice/".$flow_id, 
'CallerId' => "044-481-37003",
'CallType' => "trans" 
); 
#Replace <subdomain> with the region of your account
#<subdomain> of Singapore cluster is @api.exotel.com
#<subdomain> of Mumbai cluster is @api.in.exotel.com 
$url = "https://" . $api_key .  ":"  . $api_token . "@api.exotel.com/v1/Accounts/" .     $exotel_sid . "/Calls/connect"; 
$ch  = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
$http_result = curl_exec($ch);
curl_close($ch);
echo "<pre>";
print "Response = ".print_r($http_result);
?>

Try out this code.