php 处理raw数据,php以raw格式传递数据
該樓層疑似違規已被系統折疊?隱藏此樓查看此樓
最近跟京東合作,對接京小康,跟他們交流后明白 php這邊得以raw格式的數據區請求他們的接口
網上也搜索了一些例如下面
function http_post($url, $data_string) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-AjaxPro-Method:ShowList',
'Content-Type: application/json; charset=utf-8',
'Content-Length: ' . strlen($data_string))
);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
還是請求不到,請求參數是沒問題的 postman測試過可以獲取到數據
又查到了一個是這樣的
function curls($url, $data_string) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-AjaxPro-Method:ShowList',
'User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36' ));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
不出所料依然失敗,網上也搜了半天沒有其他的說明了,在此請教萬能的吧友們解決一下在此拜謝了
總結
以上是生活随笔為你收集整理的php 处理raw数据,php以raw格式传递数据的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 将query存进数组 php,think
- 下一篇: java添加时间,如何通过Java中的a