How to send JSON data in body with header using post method in PHP(cURL)
This question already has an answer here:
You can Use below code to achieve your goal
$jsonData1_get_r = array(
'customerMobileNo'=>'9040845440',
'recipientMobileNo'=>'7008565316',
'recipientName'=>'Name Test Test',
'accountNo'=>'5928374737328009',
'bankName'=>'HDFC',
'accIfsc'=>'HDFC0002058',
'transactionType'=>'IMPS',
'amount'=>'100'
);
$jsonDataEncoded_get = json_encode($jsonData1_get_r );
$ch_get = curl_init($url_get);
curl_setopt($ch_get, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch_get, CURLOPT_POSTFIELDS, $jsonDataEncoded_get );
curl_setopt($ch_get, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch_get, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Authorization: ' . $token)
);
Hope you this will helps you !!
Thanks & Regards
链接地址: http://www.djcxy.com/p/48894.html上一篇: 使用php代理的请求的数据体