Curl Request sent

$url = 'http://localhost/TEST/news_app_api/devices/register';

// Any other field you might want to post
$json_data = json_encode(array(
"device_id"=>2,
"app_id"=>3,
"access_token"=>'yes',
"cloud_id"=>4,
));

$post_data = $json_data;
/*curl_setopt_array($curl, array(
   CURLOPT_RETURNTRANSFER => 1,
   CURLOPT_URL => $url,
   CURLOPT_USERAGENT => 'Yamaha'
));*/

// Set URL on which you want to post the Form and/or data
curl_setopt($curl, CURLOPT_URL, $url);
// Data+Files to be posted
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
// Pass TRUE or 1 if you want to wait for and catl the response against the request made
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// For Debug mode; shows up any error encountered during the operation
curl_setopt($curl, CURLOPT_VERBOSE, 1);

// Send the request & save response to $resp
$data = curl_exec($curl);
// Close request to clear up some resources
curl_close($curl);
//var_dump($data);die;
if(!$data)
   die('Error: "' . curl_error($curl) . '" - Code: ' . curl_errno($curl));

$scheduleData = CJSON::decode($data);
return $scheduleData;

Share this

Related Posts

Previous
Next Post »