临时二维码请求说明
http请求方式: POST URL: https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=TOKEN POST数据格式:json POST数据例子:{"expire_seconds": 604800, "action_name": "QR_SCENE", "action_info": {"scene": {"scene_id": 123}}}
原文地址:http://mp.weixin.qq.com/wiki/18/28fc21e7ed87bec960651f0ce873ef8a.html
探究下微信那边是怎么接收到这个json串的:
index1.php的页面:
$post_url = 'http://localhost/wlphp/index2.php?id=1';
$post_data = '{"expire_seconds": 1800, "action_name": "QR_SCENE", "action_info": {"scene": {"scene_id": time()}}}';//$output_news处理好的数组
$ch = curl_init();//初始化
curl_setopt($ch, CURLOPT_TIMEOUT, '30');//超时时间
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Keep-Alive: 300','Connection: keep-alive')) ;
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; GTB7.4; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)');
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_URL,$post_url);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post_data);
$contents = curl_exec($ch);
if(curl_errno($ch)){
print curl_error($ch);
}
index2.php的页面:
<?php
echo (file_get_contents('php://input')); //接收到传过来的json 进行逻辑处理然后返回 我这里就返回了传递过来的json
?>
index页面显示结果:
{"expire_seconds": 1800, "action_name": "QR_SCENE", "action_info": {"scene": {"scene_id": time()}}}
成功获取了返回值!