Google News
logo
PHP - Interview Questions
How to Pass JSON Data in a URL using CURL in PHP?
Code to post JSON Data in a URL using CURL in PHP
 
$url='https://www.freetimelearning.com/get_details';
$jsonData='{"name":"phpScots",
"email":"phpscots@freetimelearning.com"
,'age':28
}';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
curl_close($ch);
Advertisement