折騰到半夜,搞得挺興奮,總結一下,免得忘了:
3、在getuserinfo的返回資料中,有加密資訊,
res包括userinfo,iv,rawdata,signature,encrypteddata,這些東西的關係比較複雜,我理解是這樣的:wx.getuserinfo(
})
1)userinfo包括簡單的使用者資訊2)重要資訊在encrypteddata中,解開後包括:
3)要解開的話,需要密文-encrypteddata,向量-iv,金鑰-session-key。金鑰這裡沒有。4、session-key的獲取方式:4)rawdata,signature是來做校驗的,不太關心
1)登入成功後,傳給**的引數包括乙個code,但這個code會很快失效2)通過呼叫
可以獲得session-key和openid。除了code,其他引數很簡單,文件裡有說明。我的小程式:簡單賬本道理搞明白其實就很簡單了,獲得了openid,其實也沒用必要再去解密了,因為那裡除了openid,也沒啥想要的東西。
參考:
微信小程式 獲取使用者資訊
第一種獲取方案 1 首先呼叫wx.login 介面 讓使用者授權驗證,也就是我們肉眼觀察到的,你是否對 xx授權這種資訊。2 使用者成功授權後,呼叫wx.getuserinfo 介面獲取使用者資訊。完整 如下 wx login 第二種比較複雜了,需要與後台進行互動才能獲得userinfo,但是這種方...
微信小程式獲取使用者資訊
後端解密,獲得使用者具體資訊。官方介面文件 使用spring boot中的resttemplate來傳送請求 public loginresult dologin string code catch exception e 官方介面文件 org.bouncycastlegroupid bcprov ...
微信小程式獲取使用者資訊
getuserinfo bind getuserinfo getuserinfo 獲取使用者資訊 button 獲取應用例項 這是全域性變數的配置 data hasuserinfo false caniuse wx.caniuse button.open type.getuserinfo 這是判斷是...