// 微信网页 授权
public function webshouquan(){
$appid='wxe8e124312cfb2176';
// 回调地址
$redirect_uri = 'http://www.chenxi521.com/index.php/api/api/callbackwxurl';
$url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='. $appid
. "&redirect_uri=" . urlencode($redirect_uri)
. "&response_type=code"
. "&scope=snsapi_userinfo"
. "&state=STATE#wechat_redirect";
$this->assign('url', $url);
return $this -> fetch();
}
// 微信网页 授权回调
public function callbackwxurl(){
// 微信保持code 5分钟有效; 5分钟内code不变,若重复获取,微信会提示code已经使用过了
$code = input('get.code');
$appid = 'wxe8e124312cfb2176';
$secret = 'ebf127d57a2af1a1ebf05f12de541c00';
$url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=".$appid
. "&secret=".$secret
. "&code=".$code
. "&grant_type=authorization_code";
$WxInfo = $this -> curlGet($url);
$info = json_decode($WxInfo, TRUE);
// 网页授权接口调用凭证access_token与基础API的access_token不同
$access_token = $info['access_token'];
$openid = $info['openid'];
// 判断 access_token 是否有效
$checkUrl = "https://api.weixin.qq.com/sns/auth?access_token=" .$access_token
."&openid=" . $openid;
$checkRes = $this -> curlGet($checkUrl);
$jsonRes = json_decode($checkRes);
$errorcode= $jsonRes->errcode;
if($errorcode == 0){
// 获取微信信息
$url = "https://api.weixin.qq.com/sns/userinfo?access_token=".$access_token
. "&openid=" . $openid
. "&lang=zh_CN";
$wxUser = $this -> curlGet($url);
var_dump($wxUser);
}
}
为何 第二个红框 写错了,导致tp报错, 而 tp 回溯提示 是第一个红框存在问题呢?

有个疑问 ,就是 为何 第二个红框 写错了,导致报错的位置为何是第一个红框处呢???
是 tp 回溯 有问题?
@thinkPHP
最佳答案