PHP JSON HTTP POST
I have a server which accepts HTTP Post request with JSON body and sends response in JSON. 开发者_StackOverflow中文版I dont know any way in PHP to do this.
I need to send a request to server with the JSON body
{
MyName="Hitesh"
MyPhone="8008288081"
}
Any help will be highly appreciated.
The API is available in a server hosted at xyz.hitesh.com and the PHP code will be hosted at abc.test.com
$requestBody = file_get_contents('php://input');
$requestBody = json_decode($requestBody);
// ???
$response = array('Accepted' => 'Yes');
header('Content-Type: application/json');
echo json_encode($response);
精彩评论