开发微信的应用,后台获取到OpenID,可以据此来获取用户的基本信息,PHP的示例代码如下:

<?php
$url="https://api.weixin.qq.com/cgi-bin/user/info?access_token=".ACCESS_TOKEN."&openid=".$OpenID."&lang=zh_CN";
$result=json_decode(file_get_contents($url), true);
$nickname=$result['nickname'];
$headimgurl=$result['headimgurl'];
/*正常返回示例
{
"subscribe": 1,
"openid": "o6_bmjrPTlm6_2sgVt7hMZOPfL2M",
"nickname": "Band",
"sex": 1,
"language": "zh_CN",
"city": "广州",
"province": "广东",
"country": "中国",
"headimgurl": "http://wx.qlogo.cn/mmopen/g3MonUZtNHkdmzicIlibx6iaFqAc56vxLSUfpb6n5WKSYVY0ChQKkiaJSgQ1dZuTOgvLLrhJbERQQ4eMsv84eavHiaiceqxibJxCfHe/0",
"subscribe_time": 1382694957,
"unionid": " o6_bmasdasdsad6_2sgVt7hMZOPfL"
"remark": "",
"groupid": 0
}
*/

Related Posts: PHP-微信根据OpenID获取用户基本信息示例 :