极光分享调用授权api失败 JShareInterface.authorize(Wechat.Name, new AuthListener()
分享微信和盆友圈可以正常使用,但是调用授权接口一点反应都没有,代码如下:
JShareInterface.authorize(Wechat.Name, new AuthListener() {
@Override
public void onComplete(Platform platform, int i, BaseResponseInfo data) {
String toastMsg = null;
switch (mAction) {
case Platform.ACTION_AUTHORIZING:
if (data instanceof AccessTokenInfo) { //授权信息
String token = ((AccessTokenInfo) data).getToken();//token
long expiration = ((AccessTokenInfo) data).getExpiresIn();//token有效时间,时间戳
String refresh_token = ((AccessTokenInfo) data).getRefeshToken();//refresh_token
String openid = ((AccessTokenInfo) data).getOpenid();//openid
String unionid = "";//openid
//授权原始数据,开发者可自行处理
String originData = data.getOriginData();
toastMsg = "授权成功:" + data.toString();
Log.e("weixin_login", "openid:" + openid + ",token:" + token + ",expiration:" + expiration + ",refresh_token:" + refresh_token);
Log.e("weixin_login", "originData:" + originData);
Toast.makeText(LoginActivity.this, originData, Toast.LENGTH_SHORT).show();
Toast.makeText(LoginActivity.this, toastMsg, Toast.LENGTH_SHORT).show();
getLoginByOpenid(openid,unionid,"appid");
}
Toast.makeText(LoginActivity.this, "haha11", Toast.LENGTH_SHORT).show();
break;
}
Toast.makeText(LoginActivity.this, "haha22", Toast.LENGTH_SHORT).show();
}
@Override
public void onError(Platform platform, int i, int i1, Throwable throwable) {
String toastMsg = null;
switch (mAction) {
case Platform.ACTION_AUTHORIZING:
toastMsg = "授权失败,无法登录";
Toast.makeText(LoginActivity.this, toastMsg, Toast.LENGTH_SHORT).show();
break;
}
Toast.makeText(LoginActivity.this, "haha33", Toast.LENGTH_SHORT).show();
}
@Override
public void onCancel(Platform platform, int i) {
Log.e("weixin_login", "onCancel:" + platform + ",action:" + mAction);
String toastMsg = null;
switch (mAction) {
case Platform.ACTION_AUTHORIZING:
toastMsg = "您已经取消授权,登录失败";
Toast.makeText(LoginActivity.this, toastMsg, Toast.LENGTH_SHORT).show();
break;
}
Toast.makeText(LoginActivity.this, "haha44", Toast.LENGTH_SHORT).show();
}
});
发现没有进入回调里面,不管是失败还是成功都没有,不知道是什么原因,哪位大神能否指导一下,非常感谢!