获取用户微信上的所在地

来源:互联网 发布:陈真新传 知乎 编辑:程序博客网 时间:2024/04/29 14:44

获取微信用户的所在地,不是扫码时的

//获取用户微信上的所在地function getLocation($openid){$token =getWeiXinAccessToken();//获取token,http://blog.csdn.net/qq_21119773/article/details/51681382有这个方法$token_access_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" . $token . "&openid=" . $openid;//目标用户的openid$res = file_get_contents($token_access_url); //获取文件内容或获取网络请求的内容if($res) {$result = json_decode($res, true); //接受一个 JSON 格式的字符串并且把它转换为 PHP 变量if(isset($result['country'])&&isset($result['province'])&&isset($result['city']))return $result['country'].$result['province'].$result['city'];else return "";}else return "";}


0 0
原创粉丝点击