
微信公众号 开发 40163 code been used
一直说我 code 被用。但代码事实是没有用啊,
经过 https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=http://HOST/index/index/index?activityId={$Request.param.activityId}&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect
微信重定向后 直接就进入到下面的处理代码里(中间没有任何的其它东西,这 code 怎么会是被使用了呢?)
if(!Session::has('userInfo')){ $code = $params['code']; //获取特殊的 access_token $url = "https://api.weixin.qq.com/sns/oauth2/access_token"; $params['appid']= config('appid'); $params['secret']= config('appsecret'); $params['code'] = $code; $params['grant_type']='authorization_code'; //定义返回值接收变量; $httpstr = http($url, $params, 'GET', array("Content-type: text/html; charset=")); //这里是代码报错位置 $httpstr 返回 40163 code been used $access_token = $httpstr['access_token']; $openid = $httpstr['openid']; //根据 openid 获取用户信息 $args['access_token'] = $access_token; $args['openid'] = $openid; $args['lang'] = 'zh_CN'; $infoUrl = "https://api.weixin.qq.com/sns/userinfo"; $userInfo = http($infoUrl, $args, 'GET', array("Content-type: text/html; charset=")); //不再支付微信公众平台 所以 APPID 改为 sessionid 为了后面的代码不进行修改 所以这里把 openid 字段来记录 sessionid //$userInfo = new \stdClass(); //$userInfo->openid = session_id(); Session::set('userInfo', $userInfo); }