V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
JasonTsang
V2EX  ›  PHP

微信公众号 开发 40163 code been used

  •  
  •   JasonTsang · 2018-12-23 11:57:56 +08:00 · 3897 次点击
    这是一个创建于 1948 天前的主题,其中的信息可能已经有所发展或是发生改变。

    微信公众号 开发 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=utf-8"));
    			
                //这里是代码报错位置 $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=utf-8"));
    
    
    			//不再支付微信公众平台 所以 APPID 改为 sessionid  为了后面的代码不进行修改 所以这里把 openid 字段来记录 sessionid
    			//$userInfo = new \stdClass();
    			//$userInfo->openid = session_id();
    			Session::set('userInfo', $userInfo);
    		}
            
    
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1904 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 16:24 · PVG 00:24 · LAX 09:24 · JFK 12:24
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.