/**
* 发送post请求
* @param type $url
* @param type $data
* @return type 失败返回false
*/
public function sendPost($url, $data = array()) {
$status = false;
if (empty($url)) {
echo '亲,URL都没有,你要POST到哪去?';
$status = false;
return $status;
}
// $post_data['data']=$this->hb_en($data);//加密
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
ob_start();
curl_exec($ch);
$result = ob_get_contents();
ob_end_clean();
// if (!empty($result)) {
// $result = $this->ajaxReturn($result);
// }
return $result;
* 发送post请求
* @param type $url
* @param type $data
* @return type 失败返回false
*/
public function sendPost($url, $data = array()) {
$status = false;
if (empty($url)) {
echo '亲,URL都没有,你要POST到哪去?';
$status = false;
return $status;
}
// $post_data['data']=$this->hb_en($data);//加密
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
ob_start();
curl_exec($ch);
$result = ob_get_contents();
ob_end_clean();
// if (!empty($result)) {
// $result = $this->ajaxReturn($result);
// }
return $result;
}
api调用 sendPost($url,$data)