//授权
private void authorization(SHARE_MEDIA share_media) {
final UMShareConfig config = new UMShareConfig();
config.isNeedAuthOnGetUserInfo(true);
UMShareAPI umShareAPI = UMShareAPI.get(this);
umShareAPI.setShareConfig(config);
umShareAPI.getPlatformInfo(this, share_media, new UMAuthListener() {
@Override
public void onStart(SHARE_MEDIA share_media) {
Log.d(TAG, "onStart " + "授权开始");
}
@Override
public void onComplete(SHARE_MEDIA share_media, int i, Map<String, String> map) {
Log.d(TAG, "onComplete " + "授权完成");
String uid = map.get("uid");
HashMap<String, String> hashMap = new HashMap<>();
// hashMap.put("unionid", map.get("unionid"));
// hashMap.put("open_id", map.get("openid"));
// hashMap.put("nick_name", map.get("name"));
// hashMap.put("sex", map.get("gender"));
// hashMap.put("headimgurl", map.get("iconurl"));
// hashMap.put("city", map.get("city"));
// hashMap.put("province", map.get("province"));
// hashMap.put("country", map.get("country"));
// hashMap.put("unionid", map.get("unionid"));
// hashMap.put("openid", map.get("openid"));
// 助记词的解密
// hashMap.put("nickname", map.get("name"));
// hashMap.put("avatar", map.get("iconurl"));
// hashMap.put("method", urlManage.LOGIN_WECHAT);
// getP().requestGet(LoginWxType, urlManage.Is_wechat, hashMap);
intent_resign = new Intent(LoginActivity.this, RegisterActivity.class);
intent_resign.putExtra("nickname", map.get("name"));
intent_resign.putExtra("headimgurl", map.get("iconurl"));
intent_resign.putExtra("openid", map.get("openid"));
intent_resign.putExtra("unionid", map.get("unionid"));
intent_resign.putExtra("type", "Wxchat");
// startActivity(intent);
hashMap.put("method", urlManage.Is_wechat);
hashMap.put("unionid", map.get("unionid"));
hashMap.put("timestamp", TimeUtil.getTimeLong() + "");
String sign = Encrypt.encrytSHA256(hashMap, null);
hashMap.put("sign", sign);
Aes aes=new Aes();
HashMap<String,String> data=aes.getAesParam(hashMap,sign);
getP().requestPost(Is_wechat, getLoginUrl, data);
}
@Override
public void onError(SHARE_MEDIA share_media, int i, Throwable throwable) {
Log.d(TAG, "onError " + "授权失败");
}
@Override
public void onCancel(SHARE_MEDIA share_media, int i) {
Log.d(TAG, "onCancel " + "授权取消");
}
});
}