Exemplo n.º 1
0
Arquivo: api.php Projeto: dlpc/ecshop
 //链接消息
 /*
 	$xml_file = '<xml>
 <ToUserName><![CDATA[toUser]]></ToUserName>
 <FromUserName><![CDATA[fromUser]]></FromUserName>
 <CreateTime>1351776360</CreateTime>
 <MsgType><![CDATA[link]]></MsgType>
 <Title><![CDATA[公众平台官网链接]]></Title>
 <Description><![CDATA[公众平台官网链接]]></Description>
 <Url><![CDATA[url]]></Url>
 <MsgId>1234567890123456</MsgId>
 </xml>';
 */
 $arr_data = array();
 $arr_data['action'] = 'receive_msg';
 $arr_data['msg'] = $obj_weixin->iconv_charset($xml_file, "GBK", 'UTF-8');
 //$arr_data['msg'] = $xml_file;
 //$arr_data['msg'] = parse_str(file_get_contents('php://input'), $_POST);
 $arr_result = $obj_weixin->weixin($arr_data);
 echo '<pre>';
 print_r($arr_result);
 echo '</pre>';
 //exit;
 if ($arr_result['MsgType'] == 'text') {
     //发送被动响应消息
     $arr_data = array();
     $arr_data['action'] = 'send_msg';
     $arr_data['ToUserName'] = $arr_result['ToUserName'];
     $arr_data['FromUserName'] = $arr_result['FromUserName'];
     $arr_data['CreateTime'] = $arr_result['CreateTime'];
     $arr_data['MsgType'] = $arr_result['MsgType'];