PHP 8 , PHP
Today i will explained how to send PHP Curl POST Request With Parameters Using Json Example. This example is so easy to use in php.
This Example to i am explained to how to send curl post request in json using php to explained in this example. So let's start to the example and follow to the my all step.
$url = 'https://api.Nicesnippets.com/api/users';
$data = array("first_name" => "First name","last_name" => "last name","email"=>"firstname.lastname@example.org");
$postdata = json_encode($data);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$result = curl_exec($ch);
Finally resize to the your file in your folder.
So, finally we are done with our code we can get below output.