question

andrew-auger13595 avatar image
andrew-auger13595 asked Phong Vu answered

problem with curl in php on ring-out


$ch = curl_init();

curl_setopt($ch, CURLOPT_URL," https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/ring-out");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 
        http_build_query(array('from' => '+12048184079',
                              'to' => '+17604762222'
                                    )));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$headers = [
           "Content-Type: application/json",
           "Accept: application/json",
           "Authorization: Bearer U0pDMTFQMDFQQVMwMHxBQUFtdWhQcG5lYk4xbUIwc2pyaXpqTVZJZnlxUWhENlEtc2NRcTNxYmZaRXl5Qk9nSWk2RDFiMjVFTy0zaXhsVGlWNF9QWWRPMEVYNENYQjd4dmJsWHJoVTBsTVl2VlA1XzNIczcycTVONm13eDY5d3o3YWkwN3l5Wkt3clFLVDl0Y3FmajJQZ0tRSUtmRnhjNGJua1lHbmxxSElJTzBnOUxab0dZR19MVlo5bGhDU2pMcE1oYm5jRG9icVRYbUswSm14VzI3VmdrNjR2aVZxUGt6bU9aOUN8amhaMGtnfFZFM1ZGamhpaTdKcjc2dkRzSDEzMGd8QUE"
            
               ];

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$server_output = curl_exec($ch);

echo "<pre>"; print_r($server_output); die;

curl_close ($ch);



output: -


{    "errorCode" : "InvalidJson",    "message" : "Unrecognized token 'from': was expecting 'null', 'true', 'false' or NaN\n at line: 1, column: 6",    "errors" : [ ] 
}
General Topic
1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Tyler Liu avatar image
Tyler Liu answered
Please use

from: { phoneNumber: '+12048184079' } 

instead of

from: '+12048184079'
1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image
Phong Vu answered
Hi Andrew,

The content type is "application/json". Here is the way to create the body for the API call

$params = array(
        'from' => array('phoneNumber' => '+12048184079'),
        'to' => array('phoneNumber' => '+17604762222')
        );
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));


+ Phong
   
1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys