问答详情
源自:1-2 基础授权代码实现

getWxCode这个函数是啥时候封装的。我一直看视频咋没有看到。

//获取用户的openid

function getBaseInfo(){

//1.获取到code

$appid = "wx878587085d5d8cc6";

$redirect_uri = urlencode("http://guoyuzhao.xinliu.org/App/imooc.php/Index/getWxCode");

$url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=".$appid."&redirect_uri=".$redirect_uri."&response_type=code&scope=snsapi_base&state=123#wechat_redirect";

header('location:'.$url);

}


function getUserOpenId(){

//2.获取到网页授权的access_token

$appid = "wx878587085d5d8cc6";

$appsecret = "5e103535b2e461158745da3b5e30d515";

$code = $_GET['code'];

$url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=".$appid."&secret=".$appsecret"&code=".$code."&grant_type=authorization_code ";

//3.拉取用户的openid

$res = $this->http_curl($url,'get');

var_dump($res);

}


提问者:会长001 2016-08-01 13:00

个回答

  • 潮zack
    2016-08-02 14:15:52
    已采纳

    仔细看视频 他之后改了 没和你说 他改成getUserOpenId了