开发者

PHP JSON HTTP POST

开发者 https://www.devze.com 2023-02-07 05:51 出处:网络
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 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

精彩评论

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