热门搜索:
http请求方式: GET https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN
{ "subscribe": 1,"openid": "o7Lp5t6n59DeX3U0C7Kric9qEx-Q","nickname": "方倍","sex": 1,"language": "zh_CN","city": "深圳","province": "广东","country": "中国","headimgurl": "http://wx.qlogo.cn/mmopen/Kkv3HV30gbEZmoo1rTrP4UjRRqzsibUjT9JClPJy3gzo0NkEqzQ9yTSJzErnsRqoLIct5NdLJgcDMicTEBiaibzLn34JLwficVvl6/0","subscribe_time": 1389684286 }
{"errcode":40013,"errmsg":"invalid appid"}
<?php //scope=snsapi_base 实例 $appid='wx87b99a9999266'; $redirect_uri = urlencode ( 'http://http://127.0.0.1/YiBaoJH/login.html' ); $url ="https://open.weixin.qq.com/connect/oauth2/authorize?appid=$appid&redirect_uri=$redirect_uri&response_type=code&scope=snsapi_base&state=1#wechat_redirect"; header("Location:".$url); ?>
<?php require_once "lib.php"; $appid = "wx89999999266"; $secret = "4dd3a9999999999993fbc490f6e52"; $code = $_GET["code"]; p($code); 第一步:取得openid $oauth2Url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=$appid&secret=$secret&code=$code&grant_type=authorization_code"; $oauth2 = getCatch($oauth2Url); $oauth2 = json_decode($oauth2,true); p($oauth2); 第二步:根据全局access_token和openid查询用户信息 $access_token = $oauth2["access_token"]; $openid = $oauth2['openid']; $get_user_info_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=$access_token&openid=$openid&lang=zh_CN"; $get_user_info_url = "https://api.weixin.qq.com/sns/userinfo?access_token=$access_token&openid=$openid&lang=zh_CN"; $userinfo_json = getCatch($get_user_info_url); $userInfo_arr = json_decode($userinfo_json,1)">p($userInfo_arr); $headimgurl = $userInfo_arr['headimgurl']; $headimgurl_tmpl = substr($headimgurl,-1); $headimgurl = $headimgurl_tmpl."132"; ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1.0,user-scalable=no"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <title>微信公众平台应用开发实战(第二版)</title> <link rel="stylesheet" href="https://d10ajoocuyu32n.cloudfront.net/mobile/1.3.1/jquery.mobile-1.3.1.min.css"> <!-- Extra Codiqa features --> <link rel="stylesheet" href="codiqa.ext.css"> <!-- jQuery and jQuery Mobile --> <script src="https://d10ajoocuyu32n.cloudfront.net/jquery-1.9.1.min.js"></script> <script src="https://d10ajoocuyu32n.cloudfront.net/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script> <!-- Extra Codiqa features --> <script src="https://d10ajoocuyu32n.cloudfront.net/codiqa.ext.js"></script> <script> document.addEventListener('WeixinJSBridgeReady',1)">function onBridgeReady() { WeixinJSBridge.call('hideOptionMenu'); WeixinJSBridge.call('hideToolbar'); }); </script> </head> <body> <!-- Home --> <div data-role="page" id="page1"> <div data-role="content"> <div style="width:132px ; height: 132px; background-color: #fbfbfb; border: 1px solid #b8b8b8;"> <img src="<?php echo $headimgurl; ?>" alt="image"> </div> <!--<div data-role="fieldcontain"> <label for="textinput1"> headimageurl: </label> <input name="" id="textinput1" placeholder="" value="<?php //echo $headimgurl;?>" data-mini="true" type="text"> </div>--> <div data-role="fieldcontain"> <label 用户的唯一标识openid: </label> <input name="" id="textinput1" placeholder="" value="<?php echo $userInfo_arr['openid']; ?>" data-mini="true" type="text"> </div> <div data-role="fieldcontain"> <label for="textinput2"> 用户昵称: </label> <input name="" id="textinput2" placeholder="" value="<?php echo $userInfo_arr['nickname']; ?>" data-mini="true"for="textinput3"> 性别(1时是男性,值为2时是女性,值为0时是未知): </label> <input name="" id="textinput3" placeholder="" value="<?php echo $userInfo_arr['sex']; ?>" data-mini="true"for="textinput4"> 客户端所用的语言: </label> <input name="" id="textinput4" placeholder="" value="<?php echo $userInfo_arr['language']; ?>" data-mini="true"for="textinput5"> 城市: </label> <input name="" id="textinput5" placeholder="" value="<?php echo $userInfo_arr['city']; ?>" data-mini="true"for="textinput7"> 省份: </label> <input name="" id="textinput7" placeholder="" value="<?php echo $userInfo_arr['province']; ?>" data-mini="true"for="textinput8"> 国家: </label> <input name="" id="textinput8" placeholder="" value="<?php echo $userInfo_arr['country']; ?>" data-mini="true"for="textinput6"> 用户特权信息: </label> <input name="" id="textinput6" placeholder="" value="<?php print_r($userInfo_arr['privilege']); ?>" data-mini="true" type="text"> </div> </div> <div data-theme="a" data-role="footer" data-position="fixed"> <h3> 微信公众平台应用开发实战(v2)测试示例 </h3> </div> </div> </body> </html>
本站采用系统自动发货方式,付款后即出现下载入口,如有疑问请咨询在线客服!
咨询售后客服