function request_post($url = '', $param = '') {
if (empty($url) || empty($param)) {
return false;
}
$postUrl = $url;
$curlPost = $param;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$postUrl);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
public function send(){
//请求地址
$sUrl = 'http://xxxxxxxxxxx.com/addOrders';
$aData = array(
'order_id'=>$order_id,//预约号
'point'=>$data['collection_point'],//采集点
'name'=>$name,//姓名
);
$sResult = $this->request_post($sUrl, $aData);
dump($sResult );
}
php调用接口: 通过post提交请求
猜你喜欢
转载自blog.csdn.net/qq_21041889/article/details/118108155
今日推荐
周排行