请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

老师我的错误码出问题了,你帮我看看

这是我的代码

<?php /** * Created by PhpStorm. * User: 田博阳 * Date: 2018/9/15 * Time: 12:34 */ namespace app\api\service; use app\lib\exception\WechatException; use think\Exception; class UserToken { protected $code; protected $wxAppID; protected $wxAppSecret; protected $wxLoginUrl; function __construct($code) { $this->code = $code; $this->wxAppID = config('wx.app_id'); $this->wxAppSecret = config('wx.app_secret'); $this->wxLoginUrl=sprintf(config('wx.login_url'),$this->wxAppID,$this->wxAppSecret,$this->code); } public function get() { $result = curl_get($this->wxLoginUrl); $wxResult = json_decode($result, true); if (empty($wxResult)) { throw new Exception('获取session_key及openID时异常,微信内部错误'); } else { $loginFail = array_key_exists("errcode", $wxResult); if ($loginFail) { $this->processLoginError($wxResult); } else { $this->grantToken($wxResult); } } return $wxResult; } private function grantToken($wxResult){ //拿到openid //数据库里看一下,这个openid是不是已经存在 //如果存在,则不处理,如果不存在那么新增一条user记录 //生成令牌,准备缓存数据,写入缓存 //把令牌返回到客户端去 $openid=$wxResult['openid']; } private function processLoginError($wxResult) { throw new WechatException([ 'msg' => $wxResult['errmsg'], 'errorcode' => $wxResult['errcode'] ]); } } 这是我提示的错误码 { "msg": "code been used, hints: [ req_id: Iah9vA04472028 ]", "error_code": 999, "request_url": "/index.php/api/v1/token/user" } 正常情况下error_code应该提示的是41008 请问老师这是怎么回事

正在回答

1回答

7七月 2018-09-16 03:47:15

这是微信的错误,提示不是很明显吗,code been used。

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号