iOS開發中:errcode = 40163; errmsg = code been used
// 使用者同意
let paramter = ["appid" : WEIXIN_APPID,
"secret" : WEIXIN_APP_SECRET,
"code" : resp.code,
"grant_type" : "authorization_code"]
MBProgressHUD.showMessage("")
WebDataResponseInterface.shareInstance.sessionManagerOriginWebData(strUrl: "https://api.weixin.qq.com", strApi: "/sns/oauth2/access_token", parameters: paramter as NSDictionary, resquestType: RequestType.GET, outRequestTime: 20, AESCPwd: nil, isTipInfo: true, responseProgress: { _ in}, responseSuccess: { (objectSuccess) in
MBProgressHUD.hide()
let dataDict = objectSuccess as! NSDictionary
if dataDict["errcode"] == nil {
myPrint(message: "openID: \(String(describing: dataDict["openid"]!))")
// 獲取使用者資訊
self.getWeixinThirdPartyLoginUserInfo(openId: String(describing: dataDict["openid"]!), accessToken: String(describing: dataDict["access_token"]!))
} else {
myPrint(message: "errcode:\(String(describing: dataDict["errcode"]!)), errmsg:\(String(describing: dataDict["errmsg"]!))")
// 獲取本地快取的使用者資訊
self.wxAccountTitleLabel.text = "微信賬戶"
self.wxAccountValueLabel.text = UserDefaults.standard.string(forKey: "wx_nickname")
self.wxOpenID = UserDefaults.standard.string(forKey: "wx_openID")
self.currentModifyMerchant.wxAccount = self.wxAccountValueLabel.text
self.currentModifyMerchant.wxOpenID = self.wxOpenID
// 修改微信賬戶資訊
self.modifyMerchantWeiXinAccountInfo(nickName: self.currentModifyMerchant.wxAccount!, openID: self.wxOpenID!)
}
}) { (error) in
MBProgressHUD.hide()
}
呼叫的請求的這段程式碼,不要放在DispatchQueue.main.asyncAfter 中執行,否則會出現此問題;