您的位置:首页 > 移动开发 > 微信开发

php之微信开发获取用户openid的方法

2016-09-16 17:18 513 查看


微信获取用户openid:

function getOpenID($appid,$appsecret,$code){
$url="https://api.weixin.qq.com/sns/oauth2/access_token?appid=".$appid."&secret=".
$appsecret."&code=".$code."&grant_type=authorization_code";
$weixin=file_get_contents($url);//通过code换取网页授权access_token
$jsondecode=json_decode($weixin); //对JSON格式的字符串进行编码
$array = get_object_vars($jsondecode);//转换成数组
$openid = $array['openid'];//输出openid
return $openid;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: