how to send json request in php code example
Example 1: send application/json php
$url = 'http://www.example.com/api';
$ch = curl_init($url);
$data = array(
'username' => 'codexworld',
'password' => '123456');
$payload = json_encode(array("user" => $data));
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
Example 2: how to make a json request in php
<?php
$jsonurl = "http://api.wipmania.com/json";
$json = file_get_contents($jsonurl);
var_dump(json_decode($json));
?>