https://open.weixin.qq.com/connect/oauth2/authorize?appid=xxx&redirect_uri=xxx&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect
時都會重定向鏈接redirect_uri都會自動請求兩次,由於併發導致了一些問題,
{"errcode":40001,"errmsg":"invalid credential, access_token is invalid or not latest, hints: [ req_id: PSp.LA0036s182 ]"}
那麼,爲什麼會請求兩次呢?,調試時發現會訪問兩次,一次是301,頁面重定向了,第二次跟第一次就差這個參數。加上後,不再報錯。code 可以了。
後來發現只要加個屬性就不會有這個問題了。
https://open.weixin.qq.com/connect/oauth2/authorize?appid=xxx&redirect_uri=xxx&response_type=code&scope=snsapi_userinfo&state=STATE&connect_redirect=1#wechat_redirect
&connect_redirect=1 這個參數
微信支付獲取用戶openid時,報出錯誤。原因是同時配置了http和https,微信網頁oauth認證通知了兩次
刪除apache配置文件中http保留https,原因嘛就是微信通知2017-12-31日前微信開發必須使用https。
bug是在配置https以後出現的,這個提示讓我最終找到了原因。
最新更新:要麼用https,要麼用服務器端的緩存,當處理過這個code ,不再重複處理 ,直接拒絕