微信开发 获取用户基本信息 php
来源:互联网 发布:淘宝小视频怎么上传 编辑:程序博客网 时间:2024/04/28 19:11
首先你的公众号必须是企业号
<?php if(isset($_SESSION['user'])){ print_r($_SESSION['user']);//判断是否已经登录exit;}$APPID='你的APPID'; $REDIRECT_URI='授权登陆后需要跳转的界面';//url中的特殊字符如&、/等需要转码$scope='snsapi_userinfo';//需要授权$url='https://open.weixin.qq.com/connect/oauth2/authorize?appid='.$APPID.'&redirect_uri='.$REDIRECT_URI.'&response_type=code&scope='.$scope.'&state=1'.$state.'#wechat_redirect';header("Location:".$url);?>
<?php$appid = "<span style="font-family: Arial, Helvetica, sans-serif;">你的APPID</span><span style="font-family: Arial, Helvetica, sans-serif;">"; </span>$secret = "你的SECRET"; $code = $_GET["code"]; $get_token_url = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid='.$appid.'&secret='.$secret.'&code='.$code.'&grant_type=authorization_code';//获取token的url$access_token = json_decode(file_get_contents($get_token_url));$access_tokens = $access_token->access_token;$openid = $access_token->openid;$get_user_info_url = 'https://api.weixin.qq.com/sns/userinfo?access_token='.$access_tokens.'&openid='.$openid.'&lang=zh_CN'; //获取用户信息的url$user_info = json_decode(file_get_contents($get_user_info_url));$_SESSION['user'] = $user_info; echo $user_info->nickname;//得到用户信息echo $user_info->headimgurl;?>
0 0
- 微信开发 获取用户基本信息 php
- 微信授权php获取用户基本信息
- 微信授权php获取用户基本信息
- 微信开发获取用户基本信息
- 微信开发获取用户基本信息
- 微信 获取用户基本信息
- 微信获取用户基本信息
- 微信获取用户基本信息
- 微信公众号PHP开发怎么获取用户的基本信息(姓名、性别、年龄等)
- 微信网页授权获取用户基本信息--PHP
- PHP如何获取微信用户的 openid 和基本信息
- 微信网页授权获取用户基本信息--PHP
- 微信公众平台开发 网页授权获取用户基本信息
- 微信公众平台开发 网页授权获取用户基本信息
- 微信公众平台开发-网页授权获取用户基本信息
- 微信公众平台开发(76) 获取用户基本信息
- 微信公众平台开发文档 获取用户基本信息
- 微信公众平台开发(86) 获取用户基本信息
- 实习杂记(26):File的renameto的用法
- ios xml
- 设置手机网页不可长按选中元素的方法
- 关于DDR3布线规范和技巧
- swiper的基础使用(十六)
- 微信开发 获取用户基本信息 php
- Maven入门2- 添加远程仓库地址
- android 学习视频大全
- hibernate进阶之路之其他知识(六)
- e.target与e.currentTarget的作用
- uptime详解,最通俗的说明了cpu平均负载
- 图片圆形,矩形圆角
- Dagger2 概念理解
- 如何获取UA?