开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜