php 微信获取openid
来源:互联网 发布:sai软件绘画手机版 编辑:程序博客网 时间:2024/05/10 07:37
header("Content-type: text/html; charset=utf-8");$code = $_GET["code"]; $html = $_GET['state'];if(empty($code)){// 如果CODE为空,取CODE$APPID='xxxx';$REDIRECT_URI='http://zss.xxxx.com/openid/index.php';$scope='snsapi_base';//$scope='snsapi_userinfo';//需要授权$url='https://open.weixin.qq.com/connect/oauth2/authorize?appid='.$APPID.'&redirect_uri='.urlencode($REDIRECT_URI).'&response_type=code&scope='.$scope.'&state='.$html.'#wechat_redirect';header("Location:".$url);}$appid = "xxxx"; $secret = "xxxx"; $code = $_GET["code"]; $url = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid='.$appid.'&secret='.$secret.'&code='.$code.'&grant_type=authorization_code';$curl = curl_init();curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);curl_setopt($curl, CURLOPT_TIMEOUT, 500);// 为保证第三方服务器与微信服务器之间数据传输的安全性,所有微信接口采用https方式调用,必须使用下面2行代码打开ssl安全校验。// 如果在部署过程中代码在此处验证失败,请到 http://curl.haxx.se/ca/cacert.pem 下载新的证书判别文件。curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);curl_setopt($curl, CURLOPT_URL, $url);$res = curl_exec($curl);curl_close($curl); $json_obj = json_decode($res,true); $openid=$json_obj["openid"];echo 'openid=【'.$openid.'】';
阅读全文
0 0
- php 微信获取openid
- php获取微信用户的openid
- PHP获取微信粉丝的OpenID
- PHP:微信获取token,openid
- 微信获取openid
- 微信获取openid
- 获取微信OpenId
- 获取微信OpenID
- 获取微信openid
- 微信获取openid
- 微信获取openid
- 公众号获取用户的openid,php批量获取微信公众号openid
- php之微信开发获取用户openid的方法
- php微信企业号获取用户OpenId
- PHP如何获取微信用户的 openid 和基本信息
- java微信获取openid
- .NET获取微信openid
- 微信投票-获取openid
- 思考让人学有所得,学有所获
- 如何保护你的隐私(二)
- 被低估的BIRT报表(四):中文乱码的解决办法
- 安装Scrapy的心路历程
- 留学的意义2
- php 微信获取openid
- 被低估的BIRT报表(五):signer information does not match
- pyhton---模块与包的调用
- 正则表达式
- OpenCV颜色识别
- Python学习-课后作业1
- RTMP协议详解
- VisualSVN Server安裝与使用
- Mysql命令大全