curl+ post/get 提交

//测试 内容 固定为 你好  post
$curlPost = 'mobile='.$mobile.'&message='.$message.'&memberId='.$memberid;

$ch = curl_init();
$url='http://www.haibi.com.cn/sendMessage.jsp';
curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_USERAGENT, "Jimmy's CURL Example beta");

$data = curl_exec($ch);

curl_close($ch);
echo $data;

//一下是get

$url_get = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$res['AppId'].'&secret='.$res['AppSecret'];
$result = file_get_contents($url_get);
if (empty($result)){
$ch = curl_init();
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_URL, $url_get);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
}
$json = json_decode($result);

原文地址:https://www.cnblogs.com/hxl2009/p/3598750.html