internal void WeChatLogin(LoginCallBack4WeChat cb, FailureCallBack fcb) { CurPlatformType = PlatformType.WeChat; ssdk.Authorize(CurPlatformType); CurCB4WeChat += cb; CurFailureCB += fcb; // /*string res = "{\"country\":\"\", \"province\":\"\", \"nickname\":\"\u732b\u62d6\u9aa1\u62c9\", \"credential\":{\"access_token\":\"16_dKg-yNotgs3urDeZUGDbgSRkqh3O68CrFMFERufG_w9PBjM0rloVJhS0conFX-R184-h1ClBikAmyeXz4p_9F3_eeYsPEXYLdxiUrq3sw-k\", \"openid\":\"oRaVf5m9CxHO9NUwOTe5KdAUKsbQ\", \"scope\":\"snsapi_userinfo\", \"refresh_token\":\"16_B2Z9Bk0-ZTNt6vpm5F9bAfsw4GfSX6QdCRBb-OecuCizAh8b7YYtU5lbbMgXDr7hEpz9RZjzIkp7AzghiIKpfSI7Bn1IrdMEvQWhW82jubE\", \"expires_in\":7200, \"unionid\":\"oUqxL1Bbbw0zFBxL4bMRWhb4hbzI\"}, \"unionid\":\"oUqxL1Bbbw0zFBxL4bMRWhb4hbzI\", \"openid\":\"oRaVf5m9CxHO9NUwOTe5KdAUKsbQ\", \"privilege\":[], \"city\":\"\", \"sex\":0, \"language\":\"zh_CN\", \"headimgurl\":\"\"}"; * LitJson.JsonData jsonRes = LitJson.JsonMapper.ToObject(res); * LitJson.JsonData credentialData = jsonRes["credential"]; * * CurCB4WeChat(jsonRes["openid"].ToString(), jsonRes["unionid"].ToString(), credentialData["access_token"].ToString(), jsonRes["nickname"].ToString()); * CurCB4WeChat = null;*/ // }
void OnAuthResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result) { if (state == ResponseState.Success) { if (result != null && result.Count > 0) { string res = MiniJSON.jsonEncode(result); //PrintDebugInfo.Add("Authorize Success !" + "Platform:" + type + " Result:" + res); Debug.Log("=========================================="); Debug.Log(res); Debug.Log("=========================================="); /*switch(CurPlatformType) * { * case PlatformType.WeChat: * { * PrintDebugInfo.Add("解析:"); * PrintDebugInfo.Add("country:" + resData["country"].ToString()); * PrintDebugInfo.Add("refresh_token:" + resData["refresh_token"].ToString()); * PrintDebugInfo.Add("province:" + resData["province"].ToString()); * PrintDebugInfo.Add("gender:" + resData["gender"].ToString()); * PrintDebugInfo.Add("icon:" + resData["icon"].ToString()); * PrintDebugInfo.Add("unionid:" + resData["unionid"].ToString()); * PrintDebugInfo.Add("openid:" + resData["openid"].ToString()); * PrintDebugInfo.Add("nickname:" + resData["nickname"].ToString()); * PrintDebugInfo.Add("userID:" + resData["userID"].ToString()); * PrintDebugInfo.Add("city:" + resData["city"].ToString()); * PrintDebugInfo.Add("expiresTime:" + resData["expiresTime"].ToString()); * PrintDebugInfo.Add("expiresIn:" + resData["expiresIn"].ToString()); * PrintDebugInfo.Add("token:" + resData["token"].ToString()); * } * break; * case PlatformType.QQ: * { * PrintDebugInfo.Add("解析:"); * PrintDebugInfo.Add("expiresIn:" + resData["expiresIn"].ToString()); * PrintDebugInfo.Add("pfkey:" + resData["pfkey"].ToString()); * PrintDebugInfo.Add("secret:" + resData["secret"].ToString()); * PrintDebugInfo.Add("iconQzone:" + resData["iconQzone"].ToString()); * PrintDebugInfo.Add("gender:" + resData["gender"].ToString()); * PrintDebugInfo.Add("icon:" + resData["icon"].ToString()); * PrintDebugInfo.Add("pay_token:" + resData["pay_token"].ToString()); * PrintDebugInfo.Add("unionid:" + resData["unionid"].ToString()); * PrintDebugInfo.Add("nickname:" + resData["nickname"].ToString()); * PrintDebugInfo.Add("pf:" + resData["pf"].ToString()); * PrintDebugInfo.Add("secretType:" + resData["secretType"].ToString()); * PrintDebugInfo.Add("userID:" + resData["userID"].ToString()); * PrintDebugInfo.Add("expiresTime:" + resData["expiresTime"].ToString()); * PrintDebugInfo.Add("token:" + resData["token"].ToString()); * } * break; * }*/ /*iOS 微信返回值 * { * "country":"", * "province":"", * "nickname":"\u732b\u62d6\u9aa1\u62c9", * "credential": * { * "access_token":"16_dKg-yNotgs3urDeZUGDbgSRkqh3O68CrFMFERufG_w9PBjM0rloVJhS0conFX-R184-h1ClBikAmyeXz4p_9F3_eeYsPEXYLdxiUrq3sw-k", * "openid":"oRaVf5m9CxHO9NUwOTe5KdAUKsbQ", * "scope":"snsapi_userinfo", * "refresh_token":"16_B2Z9Bk0-ZTNt6vpm5F9bAfsw4GfSX6QdCRBb-OecuCizAh8b7YYtU5lbbMgXDr7hEpz9RZjzIkp7AzghiIKpfSI7Bn1IrdMEvQWhW82jubE", * "expires_in":7200, * "unionid":"oUqxL1Bbbw0zFBxL4bMRWhb4hbzI" * }, * "unionid":"oUqxL1Bbbw0zFBxL4bMRWhb4hbzI", * "openid":"oRaVf5m9CxHO9NUwOTe5KdAUKsbQ", * "privilege":[], * "city":"", * "sex":0, * "language":"zh_CN", * "headimgurl":"http://thirdwx.qlogo.cn/mmopen/vi_32/b9KoSo6KV9AlDjeViaEhFssSSBv9iaCB0NTF3rw3BXBic1yF4q6CicUjOicLElH2TPliaqiceVEG4ljIahic5JQmyVWcLg/132" * }*/ if (CurCB != null) { Dictionary <string, object> resData = Json.Deserialize(res) as Dictionary <string, object>; CurCB(resData["userID"].ToString(), resData["nickname"].ToString()); CurCB = null; } if (CurCB4WeChat != null) { LitJson.JsonData jsonRes = LitJson.JsonMapper.ToObject(res); LitJson.JsonData credentialData = jsonRes["credential"]; CurCB4WeChat(jsonRes["openid"].ToString(), jsonRes["unionid"].ToString(), credentialData["access_token"].ToString(), jsonRes["nickname"].ToString()); CurCB4WeChat = null; } } else { PrintDebugInfo.Add("Authorize Success !" + " Platform:" + type); } } else if (state == ResponseState.Fail) { #if UNITY_ANDROID PrintDebugInfo.Add("fail! throwable stack = " + result["stack"] + "; error msg = " + result["msg"]); if (CurFailureCB != null) { CurFailureCB(result["msg"].ToString()); } CurFailureCB = null; #elif UNITY_IPHONE print("fail! error code = " + result["error_code"] + "; error msg = " + result["error_msg"]); #endif } else if (state == ResponseState.Cancel) { PrintDebugInfo.Add("cancel !"); if (CurFailureCB != null) { CurFailureCB("用户取消授权登录!"); } CurFailureCB = null; } }