Send json in HTTP POST request by CURL php

A simple post operation by php curl. And send some json data.

//extract data from the post

//set POST variables
$url = '';
$jsodata='{"to":"foo", "msg":"bar", "token":"blah"}';
$fields_string ="aajgw=".$jsodata;
//open connection
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, 1); // 1 for number of params (aajgw)
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);

//execute post
$result = curl_exec($ch);
echo $result;

//close connection
  • Guest

    if your are from Please send your skype or add me
    ” zahirwattoo ” have some project to work on it. waiting your help