com.sina.weibo.sdk.exception.WeiboException Java Examples

The following examples show how to use com.sina.weibo.sdk.exception.WeiboException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SocialSSOProxy.java    From ESSocialSDK with Apache License 2.0 6 votes vote down vote up
/**
 * 登录微博
 *
 * @param context context
 * @param info    社交信息
 */
public static void logoutWeibo(final Context context, SocialInfo info) {
    if (DEBUG)
        Log.i(TAG, "SocialSSOProxy.logoutWeibo");

    WeiboSSOProxy.logout(context, info, getUser(context).getToken(), new RequestListener() {
        @Override
        public void onComplete(String s) {
            if (DEBUG)
                Log.i(TAG, "SocialSSOProxy.logoutWeibo#onComplete, s=" + s);
            removeUser(context);
        }

        @Override
        public void onWeiboException(WeiboException e) {
            if (DEBUG)
                Log.i(TAG, "SocialSSOProxy.logoutWeibo#onWeiboException, e=" + e.toString());
        }
    });
}
 
Example #2
Source File: MainActivity.java    From Simpler with Apache License 2.0 6 votes vote down vote up
/**
 * 加载分组微博
 *
 * @param groupId
 * @param maxId
 * @param refresh
 */
public void loadGroupStatuses(long groupId, long maxId, final boolean refresh) {
    if (mGroupAPI == null) {
        mGroupAPI = new GroupAPI(MainActivity.this, SinaConsts.APP_KEY, BaseConfig.sAccessToken);
    }
    mGroupAPI.timeline(groupId, 0, maxId, mRefreshCount, 1, false, 0, new RequestListener() {
        @Override
        public void onComplete(String s) {
            if (!TextUtils.isEmpty(s)) {
                formatStatusStr(s, refresh);
            }
        }

        @Override
        public void onWeiboException(WeiboException e) {
            AppToast.showToast(R.string.loading_statuses_failed);
            e.printStackTrace();
        }
    });
}
 
Example #3
Source File: MainActivity.java    From Simpler with Apache License 2.0 6 votes vote down vote up
/**
 * 加载朋友圈(双向关注的用户)微博
 */
public void loadBilateralStatuses(long maxId, final boolean refresh) {
    if (mStatusesAPI == null) {
        mStatusesAPI = new StatusesAPI(this, SinaConsts.APP_KEY, BaseConfig.sAccessToken);
    }
    mStatusesAPI.bilateralTimeline(0, maxId, mRefreshCount, 1, false, 0, false, new RequestListener() {
        @Override
        public void onComplete(String s) {
            if (!TextUtils.isEmpty(s)) {
                formatStatusStr(s, refresh);
            }
        }

        @Override
        public void onWeiboException(WeiboException e) {
            AppToast.showToast(R.string.loading_statuses_failed);
            e.printStackTrace();
        }
    });
}
 
Example #4
Source File: MainActivity.java    From Simpler with Apache License 2.0 6 votes vote down vote up
/**
 * 加载微博分组
 */
private void loadGroups() {
    // 获取用户信息接口
    if (mGroupAPI == null) {
        mGroupAPI = new GroupAPI(this, SinaConsts.APP_KEY, BaseConfig.sAccessToken);
    }
    RequestListener listener = new RequestListener() {
        @Override
        public void onComplete(String response) {
            if (!TextUtils.isEmpty(response)) {
                GroupList groupList = GroupList.parse(response);
                if (groupList != null && groupList.groupList != null) {
                    BaseConfig.sGroups = groupList.groupList;
                }
            }
        }

        @Override
        public void onWeiboException(WeiboException e) {
            e.printStackTrace();
            AppToast.showToast(R.string.loading_groups_failed);
        }
    };
    mGroupAPI.groups(listener);
}
 
Example #5
Source File: CmtMentionActivity.java    From Simpler with Apache License 2.0 6 votes vote down vote up
/**
 * 收到的评论
 *
 * @param cursor
 * @param refresh
 */
private void queryToMe(long cursor, final boolean refresh) {
    if (mCApi == null) {
        mCApi = new CommentsAPI(this, SinaConsts.APP_KEY, BaseConfig.sAccessToken);
    }
    mCApi.toME(0, cursor, 20, 1, 0, 0, new RequestListener() {
        @Override
        public void onComplete(String s) {
            mSwipeRefresh.setRefreshing(false);
            formatComments(s, refresh);
        }

        @Override
        public void onWeiboException(WeiboException e) {
            mSwipeRefresh.setRefreshing(false);
            e.printStackTrace();
            AppToast.showToast("获取数据失败");
        }
    });
}
 
Example #6
Source File: CmtMentionActivity.java    From Simpler with Apache License 2.0 6 votes vote down vote up
/**
 * 发出的评论
 *
 * @param cursor
 * @param refresh
 */
private void queryByMe(long cursor, final boolean refresh) {
    if (mCApi == null) {
        mCApi = new CommentsAPI(this, SinaConsts.APP_KEY, BaseConfig.sAccessToken);
    }
    mCApi.byME(0, cursor, 20, 1, 0, new RequestListener() {
        @Override
        public void onComplete(String s) {
            mSwipeRefresh.setRefreshing(false);
            formatComments(s, refresh);
        }

        @Override
        public void onWeiboException(WeiboException e) {
            mSwipeRefresh.setRefreshing(false);
            e.printStackTrace();
            AppToast.showToast("获取数据失败");
        }
    });
}
 
Example #7
Source File: CmtMentionActivity.java    From Simpler with Apache License 2.0 6 votes vote down vote up
/**
 * 提到我
 *
 * @param cursor
 * @param refresh
 */
private void queryMention(long cursor, final boolean refresh) {
    if (mCApi == null) {
        mCApi = new CommentsAPI(this, SinaConsts.APP_KEY, BaseConfig.sAccessToken);
    }
    mCApi.mentions(0, cursor, 20, 1, 0, 0, new RequestListener() {
        @Override
        public void onComplete(String s) {
            mSwipeRefresh.setRefreshing(false);
            formatComments(s, refresh);
        }

        @Override
        public void onWeiboException(WeiboException e) {
            mSwipeRefresh.setRefreshing(false);
            e.printStackTrace();
            AppToast.showToast("获取数据失败");
        }
    });
}
 
Example #8
Source File: UserHomepageActivity.java    From Simpler with Apache License 2.0 6 votes vote down vote up
/**
     * 查询用户信息
     *
     * @param refreshAvatar 是否更新头像缓存
     */
    private void queryUserInfo(final boolean refreshAvatar) {
        // 根据用户Id,获取用户信息
        mUsersAPI.show(Long.parseLong(BaseConfig.sUid), new RequestListener() {
            @Override
            public void onComplete(String s) {
                mSwipeRefresh.setRefreshing(false);
                if (!TextUtils.isEmpty(s)) {
//                    Log.d(TAG, s);
                    mCurUser = User.parse(s);
                    // 更新用户信息
                    BaseConfig.sUser = mCurUser;
                    initUserInfo(refreshAvatar);
                }
            }

            @Override
            public void onWeiboException(WeiboException e) {
                mSwipeRefresh.setRefreshing(false);
                e.printStackTrace();
                AppToast.showToast("获取用户信息失败");
            }
        });
    }
 
Example #9
Source File: SsoHandler.java    From letv with Apache License 2.0 6 votes vote down vote up
private void authorize(int requestCode, WeiboAuthListener listener, AuthType authType) {
    this.mSSOAuthRequestCode = requestCode;
    this.mAuthListener = listener;
    boolean onlyClientSso = false;
    if (authType == AuthType.SsoOnly) {
        onlyClientSso = true;
    }
    if (authType == AuthType.WebOnly) {
        if (listener != null) {
            this.mWebAuthHandler.anthorize(listener);
        }
    } else if (!bindRemoteSSOService(this.mAuthActivity.getApplicationContext())) {
        if (!onlyClientSso) {
            this.mWebAuthHandler.anthorize(this.mAuthListener);
        } else if (this.mAuthListener != null) {
            this.mAuthListener.onWeiboException(new WeiboException(AUTH_FAILED_NOT_INSTALL_MSG));
        }
    }
}
 
Example #10
Source File: StatusMentionActivity.java    From Simpler with Apache License 2.0 5 votes vote down vote up
/**
 * 加载用户微博
 */
private void loadStatuses(long cursor, final boolean refresh) {
    if (mStatusesAPI == null) {
        mStatusesAPI = new StatusesAPI(this, SinaConsts.APP_KEY, BaseConfig.sAccessToken);
    }

    mStatusesAPI.mentions(0, cursor, 20, 1, 0, 0, 0, false, new RequestListener() {
        @Override
        public void onComplete(String s) {
            if (!mIsResultOk) {
                mIsResultOk = true;
                setResult(RESULT_OK);
                RemindOp remindOp = new RemindOp(StatusMentionActivity.this);
                remindOp.onSetCount("mention_status");
            }

            if (!TextUtils.isEmpty(s)) {
                formatStatusStr(s, refresh);
            }
        }

        @Override
        public void onWeiboException(WeiboException e) {
            mSwipeRefresh.setRefreshing(false);
            e.printStackTrace();
            try {
                JSONObject obj = new JSONObject(e.getMessage());
                int errorCode = obj.optInt("error_code");
                if (errorCode == 10002) {
                    AppToast.showToast("服务暂不可用");
                    return;
                }
            } catch (JSONException e1) {
                e1.printStackTrace();
            }
            AppToast.showToast("暂无法获取微博信息");
        }
    });
}
 
Example #11
Source File: AboutMeActivity.java    From Simpler with Apache License 2.0 5 votes vote down vote up
private void init() {
    UsersAPI usersAPI = new UsersAPI(this, SinaConsts.APP_KEY, BaseConfig.sAccessToken);
    usersAPI.show(AUTHOR_UID, new RequestListener() {
        @Override
        public void onComplete(String s) {
            if (!TextUtils.isEmpty(s)) {
                User author = User.parse(s);
                // 加载头像
                Glide.with(AboutMeActivity.this).load(author.avatar_large).into(mCivHead);
                UserVerify.verify(author, mIvAvatarVip, mTvDescription);
                mTvName.setText(author.name);
                mAuthorScreenName = author.screen_name;
                if (author.following) {
                    // 已关注
                    mTvRelation.setText(R.string.pay_attention_ok);
                    mTvRelation.setClickable(false);
                } else {
                    // 未关注
                    mTvRelation.setText(R.string.pay_attention_to_him);
                    mTvRelation.setClickable(true);
                }
                // 点击作者头像,进入作者主页
                mCivHead.setOnClickListener(new ViewUserOp(AboutMeActivity.this, author.screen_name));
            }
        }

        @Override
        public void onWeiboException(WeiboException e) {
            e.printStackTrace();
        }
    });
}
 
Example #12
Source File: WBStatusesActivity.java    From Simpler with Apache License 2.0 5 votes vote down vote up
/**
     * 加载用户微博
     */
    private void loadStatuses(long maxId, final boolean refresh) {
        if (mStatusesAPI == null) {
            mStatusesAPI = new StatusesAPI(this, SinaConsts.APP_KEY, BaseConfig.sAccessToken);
        }

        mStatusesAPI.userTimeline(mUid, 0, maxId, mRefreshCount, 1, false, 0, false, new RequestListener() {
            @Override
            public void onComplete(String s) {
//                Log.d(TAG, s);
                if (!TextUtils.isEmpty(s)) {
                    formatStatusStr(s, refresh);
                }
            }

            @Override
            public void onWeiboException(WeiboException e) {
                mSwipeRefresh.setRefreshing(false);
                e.printStackTrace();
                try {
                    JSONObject obj = new JSONObject(e.getMessage());
                    int errorCode = obj.optInt("error_code");
                    if (errorCode == 10002) {
                        AppToast.showToast("服务暂不可用");
                        return;
                    }
                } catch (JSONException e1) {
                    e1.printStackTrace();
                }
                AppToast.showToast("暂无法获取微博信息");
            }
        });
    }
 
Example #13
Source File: UpdateRemarkActivity.java    From Simpler with Apache License 2.0 5 votes vote down vote up
@OnClick(R.id.tvOk)
void update() {
    if (mFApi == null) {
        mFApi = new FriendshipsAPI(this, SinaConsts.APP_KEY, BaseConfig.sAccessToken);
    }
    final String remark;
    if ("".equals(mEtRemark.getText().toString())) {
        if (TextUtils.isEmpty(mName)) {
            AppToast.showToast(R.string.remark_cannot_null);
            return;
        }
        remark = mName;
    } else {
        remark = mEtRemark.getText().toString();
    }
    AppToast.showToast(R.string.remark_updating);
    mFApi.remarkUpdate(mUid, remark, new RequestListener() {
        @Override
        public void onComplete(String s) {
            User user = User.parse(s);
            if (user != null && !"".equals(user.screen_name)) {
                // 更新成功
                AppToast.showToast(R.string.remark_update_success);
                Intent data = new Intent();
                data.putExtra(INTENT_NEW_REMARK, remark);
                setResult(RESULT_OK, data);
                finish();
                return;
            }
            AppToast.showToast(R.string.remark_update_failure);
        }

        @Override
        public void onWeiboException(WeiboException e) {
            e.printStackTrace();
            AppToast.showToast(R.string.remark_update_failure);
        }
    });
}
 
Example #14
Source File: WeiboLoginInstance.java    From ShareUtil with Apache License 2.0 5 votes vote down vote up
@Override
public void doLogin(Activity activity, final LoginListener listener,
        final boolean fetchUserInfo) {
    mSsoHandler.authorize(new WeiboAuthListener() {
        @Override
        public void onComplete(Bundle bundle) {
            Oauth2AccessToken accessToken = Oauth2AccessToken.parseAccessToken(bundle);
            WeiboToken weiboToken = WeiboToken.parse(accessToken);
            if (fetchUserInfo) {
                listener.beforeFetchUserInfo(weiboToken);
                fetchUserInfo(weiboToken);
            } else {
                listener.loginSuccess(new LoginResult(LoginPlatform.WEIBO, weiboToken));
            }
        }

        @Override
        public void onWeiboException(WeiboException e) {
            ShareLogger.i(INFO.WEIBO_AUTH_ERROR);
            listener.loginFailure(e);
        }

        @Override
        public void onCancel() {
            ShareLogger.i(INFO.AUTH_CANCEL);
            listener.loginCancel();
        }
    });
}
 
Example #15
Source File: WeiboLoginInstance.java    From smart-farmer-android with Apache License 2.0 5 votes vote down vote up
@Override
public void doLogin(Activity activity, final LoginListener listener,
                    final boolean fetchUserInfo) {
    mSsoHandler.authorize(new WeiboAuthListener() {
        @Override
        public void onComplete(Bundle bundle) {
            Oauth2AccessToken accessToken = Oauth2AccessToken.parseAccessToken(bundle);
            WeiboToken weiboToken = WeiboToken.parse(accessToken);
            if (fetchUserInfo) {
                listener.beforeFetchUserInfo(weiboToken);
                fetchUserInfo(weiboToken);
            } else {
                listener.loginSuccess(new LoginResult(LoginPlatform.WEIBO, weiboToken));
            }
        }

        @Override
        public void onWeiboException(WeiboException e) {
            ShareLogger.i(INFO.WEIBO_AUTH_ERROR);
            listener.loginFailure(e);
        }

        @Override
        public void onCancel() {
            ShareLogger.i(INFO.AUTH_CANCEL);
            listener.loginCancel();
        }
    });
}
 
Example #16
Source File: BaseDialog.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
@Override
public void onWeiboException(WeiboException e) {
    Log.e(TAG, "weiboListener.onWeiboException:" + e.getMessage());
    ErrorInfo ei = ErrorInfo.parse(e.getMessage());
    if (ei.error_code.equals("21332") || ei.error_code.equals("21327")) {
        AccessTokenKeeper.clear(mContext);
        shareToWeibo();
    } else {
        new CommonDialog(mContext, "微博分享", "分享失败,错误码:" + ei.error_code, "确定").show();
    }
}
 
Example #17
Source File: SharePopWindow.java    From QiQuYing with Apache License 2.0 5 votes vote down vote up
private void share2weibo() {
	setShareContent();
	// 1. 初始化微博的分享消息
       WeiboMultiMessage weiboMessage = new WeiboMultiMessage();
       weiboMessage.mediaObject = getWebpageObj();
       weiboMessage.textObject = getTextObj();    //这里可以设置文本
       if(mJoke.getType() != Joke.TYPE_QUSHI) {
       	weiboMessage.imageObject = getImageObj();
       }
      // 2. 初始化从第三方到微博的消息请求
       SendMultiMessageToWeiboRequest request = new SendMultiMessageToWeiboRequest();
       // 用transaction唯一标识一个请求
       request.transaction = String.valueOf(System.currentTimeMillis());
       request.multiMessage = weiboMessage;
       
       AuthInfo authInfo = new AuthInfo(context, com.sina.weibo.Constants.APP_KEY, com.sina.weibo.Constants.REDIRECT_URL, com.sina.weibo.Constants.SCOPE);
       Oauth2AccessToken accessToken = AccessTokenKeeper.readAccessToken(context);
       String token = "";
       if (accessToken != null) {
           token = accessToken.getToken();
       }
       mWeiboShareAPI.sendRequest((Activity)context, request, authInfo, token, new WeiboAuthListener() {
           @Override
           public void onWeiboException( WeiboException arg0 ) {
           	Log.e(TAG, "share sina weibo error", arg0);
           	ToastUtils.showMessage(context, "分享失败");
           }
           @Override
           public void onComplete( Bundle bundle ) {
               Oauth2AccessToken newToken = Oauth2AccessToken.parseAccessToken(bundle);
               AccessTokenKeeper.writeAccessToken(context, newToken);
               ImgToastUtils.showMessage(context, "分享成功", R.drawable.center_ok_tip);
           }
           @Override
           public void onCancel() {
           }
       });
}
 
Example #18
Source File: SocialShareProxy.java    From ESSocialSDK with Apache License 2.0 5 votes vote down vote up
/**
     * 分享到微博
     *
     * @param context     context
     * @param appKey      app key
     * @param redirectUrl 回调地址
     * @param scene       场景
     */
    public static void shareToWeibo(final Context context, String appKey, String redirectUrl, final SocialShareScene scene) {
        if (DEBUG)
            Log.i(TAG, "SocialShareProxy#shareToWeibo");
        WeiboShareProxy.shareTo(context, appKey, redirectUrl, scene.getTitle(), scene.getDesc(),
                scene.getThumbnail(), scene.getUrl(), new WeiboAuthListener() {
                    @Override
                    public void onComplete(Bundle bundle) {
                        if (DEBUG)
                            Log.i(TAG, "SocialShareProxy#shareToWeibo onComplete");
                        Oauth2AccessToken token = Oauth2AccessToken.parseAccessToken(bundle);
                        if (token.isSessionValid())
                            AccessTokenKeeper.writeAccessToken(context, token);
//                        BusProvider.getInstance().post(new ShareBusEvent(ShareBusEvent.TYPE_SUCCESS, scene.getType(), scene.getId()));
                    }

                    @Override
                    public void onWeiboException(WeiboException e) {
                        if (DEBUG)
                            Log.i(TAG, "SocialShareProxy#shareToWeibo onWeiboException " + e.toString());
//                        BusProvider.getInstance().post(new ShareBusEvent(ShareBusEvent.TYPE_FAILURE, scene.getType(), e));
                    }

                    @Override
                    public void onCancel() {
                        if (DEBUG)
                            Log.i(TAG, "SocialShareProxy#shareToWeibo onCancel");
//                        BusProvider.getInstance().post(new ShareBusEvent(ShareBusEvent.TYPE_CANCEL, scene.getType()));
                    }
                });

    }
 
Example #19
Source File: WBAlbumActivity.java    From Simpler with Apache License 2.0 5 votes vote down vote up
private void queryPhotos(long maxId, final boolean refresh) {
    if (mSApi == null) {
        mSApi = new StatusesAPI(this, SinaConsts.APP_KEY, BaseConfig.sAccessToken);
    }

    mSApi.userTimeline(mUid, 0, maxId, 20, 1, false, StatusesAPI.FEATURE_PICTURE, true, new RequestListener() {
        @Override
        public void onComplete(String s) {
            mSwipeRefresh.setRefreshing(false);
            StatusList statusList = StatusList.parse(s);
            if (statusList == null || statusList.statusList == null || statusList.statusList.isEmpty()) {
                mMaxId = 0;
                mAdapter.setFooterInfo(getString(R.string.no_more_data));
                return;
            }
            List<String> once = new ArrayList<>();
            for (int i = 0; i < statusList.statusList.size(); i++) {
                ArrayList<String> picUrls = statusList.statusList.get(i).pic_urls;
                if (picUrls != null && !picUrls.isEmpty()) {
                    once.addAll(picUrls);
                }
            }

            if (refresh) {
                mAdapter.setAlbums(once);
            } else {
                mAdapter.addAlbums(once);
            }
            mMaxId = statusList.statusList.get(statusList.statusList.size() - 1).id - 1;
            mAdapter.setFooterInfo(getString(R.string.pull_up_to_load_more));
        }

        @Override
        public void onWeiboException(WeiboException e) {
            mSwipeRefresh.setRefreshing(false);
            e.printStackTrace();
            AppToast.showToast("暂无法查看个人相册");
        }
    });
}
 
Example #20
Source File: MainActivity.java    From Simpler with Apache License 2.0 5 votes vote down vote up
private void loadUserInfo(UsersAPI usersAPI) {
    usersAPI.show(Long.parseLong(BaseConfig.sUid), new RequestListener() {
        @Override
        public void onComplete(String s) {
            if (!TextUtils.isEmpty(s)) {
                formatUserStr(s);      // 格式化用户信息字符串
                saveUserCache(s);    // 缓存当前用户信息
                UnreadService.startService();   // 开启未读服务
            } else {
                // 获取用户信息失败
                mOK = false;
                AppToast.showToast(R.string.failed_to_get_user_info);
            }
        }

        @Override
        public void onWeiboException(WeiboException e) {
            e.printStackTrace();
            try {
                JSONObject obj = new JSONObject(e.getMessage());
                int errorCode = obj.optInt("error_code");
                if (errorCode == 10006 || errorCode == 21332) {
                    // 授权过期
                    AppToast.showToast("应用授权过期,请重新授权");
                    if (!BaseConfig.sTokenExpired) {
                        BaseConfig.sTokenExpired = true;
                        App.getInstance().finishAllActivities();
                        startActivity(WBLoginActivity.newIntent(MainActivity.this));
                        return;
                    }
                }
            } catch (JSONException e1) {
                e1.printStackTrace();
            }
            mOK = false;
            AppToast.showToast(e.getMessage());
        }
    });
}
 
Example #21
Source File: GroupManagerActivity.java    From Simpler with Apache License 2.0 5 votes vote down vote up
private void queryGroups() {
    if (mGApi == null) {
        mGApi = new GroupAPI(this, SinaConsts.APP_KEY, BaseConfig.sAccessToken);
    }
    mGApi.groups(new RequestListener() {
        @Override
        public void onComplete(String s) {
            mSwipeRefresh.setRefreshing(false);
            // Log.d("Group", s);
            GroupList groupList = GroupList.parse(s);
            if (groupList != null && groupList.groupList != null) {
                BaseConfig.sGroups = groupList.groupList;
                mAdapter.setGroups(groupList.groupList);
                mAdapter.setFooterInfo(getString(R.string.loaded_all));
            } else {
                AppToast.showToast("获取分组失败");
            }
        }

        @Override
        public void onWeiboException(WeiboException e) {
            mSwipeRefresh.setRefreshing(false);
            e.printStackTrace();
            AppToast.showToast("获取分组失败");
        }
    });
}
 
Example #22
Source File: WBUserHomeActivity.java    From Simpler with Apache License 2.0 5 votes vote down vote up
/**
     * 查询用户信息
     */
    private void queryUserInfo() {
        // 根据用户昵称,获取用户信息
        mUsersAPI.show(mScreenName, new RequestListener() {
            @Override
            public void onComplete(String s) {
                mSwipeRefresh.setRefreshing(false);
                if (!TextUtils.isEmpty(s)) {
//                    Log.d(TAG, s);
                    mUser = User.parse(s);
                    initUserInfo();
                }
            }

            @Override
            public void onWeiboException(WeiboException e) {
                mSwipeRefresh.setRefreshing(false);
                e.printStackTrace();
                try {
                    JSONObject obj = new JSONObject(e.getMessage());
                    if (obj.optInt("error_code") == 20003) {
                        AppToast.showToast(R.string.user_does_not_exists);
                        finish();
                        return;
                    }
                } catch (JSONException e1) {
                    e1.printStackTrace();
                }
                AppToast.showToast(R.string.failed_to_get_user_info);
            }
        });
    }
 
Example #23
Source File: GroupMembersActivity.java    From Simpler with Apache License 2.0 5 votes vote down vote up
/**
 * 查询分组成员
 *
 * @param gid     分组id
 * @param cursor  游标
 * @param refresh 是否刷新列表
 */
private void queryMembers(long gid, final int cursor, final boolean refresh) {
    if (mGApi == null) {
        mGApi = new GroupAPI(this, SinaConsts.APP_KEY, BaseConfig.sAccessToken);
    }
    mGApi.members(gid, 50, cursor, new RequestListener() {
        @Override
        public void onComplete(String s) {
            mSwipeRefresh.setRefreshing(false);
            UserList userList = UserList.parse(s);
            if (userList != null && userList.users != null) {
                if (refresh) {
                    mAdapter.setData(userList.users);
                } else {
                    mAdapter.addData(userList.users);
                }
                mCursor = userList.next_cursor;
                if (mCursor > 0) {
                    mAdapter.setFooterInfo(getString(R.string.pull_up_to_load_more));
                } else {
                    mAdapter.setFooterInfo(getString(R.string.no_more_data));
                }
            } else {
                AppToast.showToast("该分组下没有好友");
            }
        }

        @Override
        public void onWeiboException(WeiboException e) {
            mSwipeRefresh.setRefreshing(false);
            e.printStackTrace();
            AppToast.showToast("获取分组好友失败");
        }
    });
}
 
Example #24
Source File: AvatarOp.java    From Simpler with Apache License 2.0 5 votes vote down vote up
public void upload(Bitmap bitmap) {
    if (mAApi == null) {
        mAApi = new AccountAPI(mContext, SinaConsts.APP_KEY, BaseConfig.sAccessToken);
    }
    mAApi.avatarUpload(bitmap, new RequestListener() {
        @Override
        public void onComplete(String s) {
            User user = User.parse(s);
            if (user != null && user.id > 0L) {
                // 头像上传成功
                if (mListener != null) {
                    mListener.onSuccess();
                }
            } else {
                if (mListener != null) {
                    mListener.onFailure(mContext.getString(R.string.avatar_upload_failure));
                }
            }
        }

        @Override
        public void onWeiboException(WeiboException e) {
            e.printStackTrace();
            if (mListener != null) {
                mListener.onFailure(mContext.getString(R.string.avatar_upload_failure));
            }
        }
    });
}
 
Example #25
Source File: WeiboSdkBrowser.java    From letv with Apache License 2.0 5 votes vote down vote up
private void startShare() {
    LogUtil.d(TAG, "Enter startShare()............");
    final ShareRequestParam req = this.mRequestParam;
    if (req.hasImage()) {
        LogUtil.d(TAG, "loadUrl hasImage............");
        new AsyncWeiboRunner(this).requestAsync(ShareRequestParam.UPLOAD_PIC_URL, req.buildUploadPicParam(new WeiboParameters(req.getAppKey())), "POST", new RequestListener() {
            public void onWeiboException(WeiboException e) {
                LogUtil.d(WeiboSdkBrowser.TAG, "post onWeiboException " + e.getMessage());
                req.sendSdkErrorResponse(WeiboSdkBrowser.this, e.getMessage());
                WeiboSdkBrowser.this.finish();
            }

            public void onComplete(String response) {
                LogUtil.d(WeiboSdkBrowser.TAG, "post onComplete : " + response);
                UploadPicResult result = UploadPicResult.parse(response);
                if (result == null || result.getCode() != 1 || TextUtils.isEmpty(result.getPicId())) {
                    req.sendSdkErrorResponse(WeiboSdkBrowser.this, "upload pic faild");
                    WeiboSdkBrowser.this.finish();
                    return;
                }
                WeiboSdkBrowser.this.openUrl(req.buildUrl(result.getPicId()));
            }
        });
        return;
    }
    openUrl(this.mUrl);
}
 
Example #26
Source File: BaseDialog.java    From AssistantBySDK with Apache License 2.0 4 votes vote down vote up
@Override
public void onWeiboException(WeiboException e) {
    Log.e(TAG, "AuthListener.onWeiboException:" + e.getMessage());
}
 
Example #27
Source File: MainActivity.java    From Simpler with Apache License 2.0 4 votes vote down vote up
/**
 * 加载微博
 */
private void loadStatuses(long maxId, final boolean refresh) {
    if (mStatusesAPI == null) {
        mStatusesAPI = new StatusesAPI(this, SinaConsts.APP_KEY, BaseConfig.sAccessToken);
    }
    mStatusesAPI.friendsTimeline(0, maxId, mRefreshCount, 1, false, 0, false, new RequestListener() {
        @Override
        public void onComplete(String s) {
            if (!TextUtils.isEmpty(s)) {
                if (refresh) {
                    // 缓存最新微博
                    SaveStatusCacheTask task = new SaveStatusCacheTask();
                    task.execute(s);
                    registerAsyncTask(MainActivity.class, task);
                }
                formatStatusStr(s, refresh);
            }
        }

        @Override
        public void onWeiboException(WeiboException e) {
            mSwipeRefresh.setRefreshing(false);
            e.printStackTrace();
            try {
                JSONObject obj = new JSONObject(e.getMessage());
                int errorCode = obj.optInt("error_code");
                if (errorCode == 10006 || errorCode == 21332) {
                    // 授权过期
                    AppToast.showToast("应用授权过期,请重新授权");
                    if (!BaseConfig.sTokenExpired) {
                        BaseConfig.sTokenExpired = true;
                        App.getInstance().finishAllActivities();
                        startActivity(WBLoginActivity.newIntent(MainActivity.this));
                    }
                }
            } catch (JSONException e1) {
                e1.printStackTrace();
            }
        }
    });
}
 
Example #28
Source File: BaseDialog.java    From AssistantBySDK with Apache License 2.0 4 votes vote down vote up
@Override
public void onWeiboException(WeiboException e) {
    Log.e(TAG, "userListener.onWeiboException:" + e.getMessage());
}
 
Example #29
Source File: LoginActivity.java    From Conquer with Apache License 2.0 4 votes vote down vote up
@Override
public void onWeiboException(WeiboException e) {
    L.i("weibo第三方登陆失败:" + e);
    T.show(context, "weibo授权失败");
}
 
Example #30
Source File: SharePopWindow.java    From QiQuYing with Apache License 2.0 4 votes vote down vote up
@Override
public void onWeiboException(WeiboException e) {
    Toast.makeText(context, 
            "Auth exception : " + e.getMessage(), Toast.LENGTH_LONG).show();
}