Thinkphp POST raw 传值

//在Common/function 添加此函数

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',
'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;
}

//在Controller 里面直接调用

public function test()

{

  $url = "http://www.xxxx.com";

   $data = array(xxxxxxx);

 $info = curls($url,$data);

  var_dump($info);

}

原文地址:https://www.cnblogs.com/leaf-cq/p/8509898.html