zoujingli / WeChatDeveloper

【新】微信服务号+微信小程序+微信支付+支付宝支付

Home Page:https://www.kancloud.cn/zoujingli/wechat-developer/content

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

code been used

fym0121 opened this issue · comments

commented

n uncaught Exception was encountered
Type: WeChat\Exceptions\InvalidResponseException

Message: code been used, hints: [ req_id: FfhfgP.Ce-9Wexoa ]

Filename: /data/home/qxu1142170109/htdocs/ygcj/application/vendor/zoujingli/wechat-developer/WeChat/Contracts/BasicWeChat.php

Line Number: 177

Backtrace:

File: /data/home/qxu1142170109/htdocs/ygcj/application/vendor/zoujingli/wechat-developer/WeChat/Oauth.php
Line: 54
Function: httpGetForJson

File: /data/home/qxu1142170109/htdocs/ygcj/application/controllers/Wx.php
Line: 63
Function: getOauthAccessToken

File: /data/home/qxu1142170109/htdocs/ygcj/index.php
Line: 315
Function: require_once


用的ci框架,composer安装在application目录下,配置已开启自动引入

config = array( 'token' => 'aaaa', // 填写你设定的key 'appid' => 'aaaa', // 填写高级调用功能的app id, 请在微信开发模式后台查询 'appsecret' => 'aaaa', // 填写高级调用功能的密钥 'encodingaeskey' => '', // 填写加密用的EncodingAESKey(可选,接口传输选择加密时必需) 'mch_id' => '', // 微信支付,商户ID(可选) 'partnerkey' => '', // 微信支付,密钥(可选) 'ssl_cer' => '', // 微信支付,双向证书(可选,操作退款或打款时必需) 'ssl_key' => '', // 微信支付,双向证书(可选,操作退款或打款时必需) 'cachepath' => '', // 设置SDK缓存目录(可选,默认位置在Wechat/Cache下,请保证写权限) ); $this->load->model("wx_model"); } public function index() { // 实例接口,同时实现接口配置验证与解密处理 $api = new \WeChat\Receive($this->config); // 第二种方法实例接口 // $api = \We::WeChatReceive($this->config); // 获取当前推送接口类型 ( text,image,loction,event... ) $msgType = $api->getMsgType(); // 获取当前推送来源用户的openid $openid = $api->getOpenid(); // 获取当前推送的所有数据 $data = $api->getReceive(); // 回复文本消息 $api->text("http://www.aaa.com/ygcj/index.php/wx/bind")->reply(); } public function bind() { // 实例接口 $wechat = new \WeChat\Oauth($this->config); // 执行操作 $result = $wechat->getOauthRedirect("http://www.aaa.com/ygcj/index.php/wx/bind_callback"); redirect($result); } public function bind_callback() { // 实例接口 $wechat = new \WeChat\Oauth($this->config); // 执行操作 $res = $wechat->getOauthAccessToken(); //有时可以,有时提示code been used if($res===FALSE){ echo "getOauthAccessToken false"; } $openid = $res["openid"]; $rows = $this->wx_model->get_custom_by_openid($openid); if(count($rows) == 0) { $data = array('openid' => $openid); $this->load->view("bind", $data); return; } } }

这个提示是说 code 已经被使用