News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
problem with curl in php on ring-out
Tags: ringout
Jan 16, 2019 at 3:44am   •   2 replies  •  0 likes
andrew-auger


$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" : [ ] 

}

2 Answers
answered on Jan 16, 2019 at 7:43am  
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
   

 0
answered on Jan 16, 2019 at 7:13am  
Please use

from: { phoneNumber: '+12048184079' } 

instead of

from: '+12048184079'

 0



A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us