getWxCode這個(gè)函數(shù)是啥時(shí)候封裝的。我一直看視頻咋沒(méi)有看到。
//獲取用戶的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.獲取到網(wǎng)頁(yè)授權(quán)的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);
}
2016-08-02
仔細(xì)看視頻 他之后改了 沒(méi)和你說(shuō) 他改成getUserOpenId了