//$post_data =“”;
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
为了支持cookie
//curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$result = curl_exec($ch);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
为了支持cookie
//curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$result = curl_exec($ch);
echo $result;
以下是解析方式
$postStr = file_get_contents("php://input");
$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
$ToUserName = (string)$postObj->ToUserName;
$FromUserName = (string)$postObj->FromUserName;
$CreateTime = (string)$postObj->CreateTime;
$MsgType = (string)$postObj->MsgTyp;
$Content = (string)$postObj->Content;
$MsgId = (string)$postObj->MsgId;
// foreach ($post_data as $k => $v) {
// $o.= "$k=" . urlencode($v) . "&";
// }