本文整理匯總了Java中com.sina.weibo.sdk.exception.WeiboException類的典型用法代碼示例。如果您正苦於以下問題:Java WeiboException類的具體用法?Java WeiboException怎麽用?Java WeiboException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
WeiboException類屬於com.sina.weibo.sdk.exception包,在下文中一共展示了WeiboException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: logoutWeibo
import com.sina.weibo.sdk.exception.WeiboException; //導入依賴的package包/類
/**
* 登錄微博
*
* @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());
}
});
}
示例2: authorize
import com.sina.weibo.sdk.exception.WeiboException; //導入依賴的package包/類
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));
}
}
}
示例3: queryUserInfo
import com.sina.weibo.sdk.exception.WeiboException; //導入依賴的package包/類
/**
* 查詢用戶信息
*
* @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("獲取用戶信息失敗");
}
});
}
示例4: loadGroups
import com.sina.weibo.sdk.exception.WeiboException; //導入依賴的package包/類
/**
* 加載微博分組
*/
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);
}
示例5: loadGroupStatuses
import com.sina.weibo.sdk.exception.WeiboException; //導入依賴的package包/類
/**
* 加載分組微博
*
* @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();
}
});
}
示例6: startGetSinsUserInfo
import com.sina.weibo.sdk.exception.WeiboException; //導入依賴的package包/類
/**
* 獲取用戶的新浪微博信息
*/
private void startGetSinsUserInfo() {
UsersAPI usersAPI = new UsersAPI(this, ShareConstant.getIns().getWeiboAppid(), mAccessToken);
usersAPI.show(mAccessToken.getUid(), new RequestListener() {
@Override
public void onComplete(String response) {
User user = User.parse(response);
if (user != null) {
AccessTokenKeeper.writeUserName(WeiboEditActivitiy.this, user.screen_name);
} else {
setAccountClick("");
}
}
@Override
public void onWeiboException(WeiboException e) {
setAccountClick("");
}
});
}
示例7: request
import com.sina.weibo.sdk.exception.WeiboException; //導入依賴的package包/類
/**
* 根據 URL 異步請求數據,並在獲取到數據後通過 {@link RequestListener}
* 接口進行回調。請注意:該回調函數是運行在後台線程的。
* 另外,在調用該方法時,成功時,會調用 {@link RequestListener#onComplete},
* {@link RequestListener#onComplete4binary} 並不會被回調,請區分 {@link #request4Binary}。
*
* @param url 服務器地址
* @param params 存放參數的容器
* @param httpMethod "GET" or "POST"
* @param listener 回調對象
*/
public static void request(
final String url,
final WeiboParameters params,
final String httpMethod,
final RequestListener listener) {
new Thread() {
@Override
public void run() {
try {
String resp = HttpManager.openUrl(
url, httpMethod, params, params.getValue("pic"));
if (listener != null) {
listener.onComplete(resp);
}
} catch (WeiboException e) {
if (listener != null) {
listener.onError(e);
}
}
}
}.start();
}
示例8: request4Binary
import com.sina.weibo.sdk.exception.WeiboException; //導入依賴的package包/類
/**
* 根據 URL 異步請求數據,並在獲取到數據後通過 {@link RequestListener}
* 接口進行回調。請注意:該回調函數是運行在後台線程的。
* 另外,在調用該方法時,成功時,會調用 {@link RequestListener#onComplete4binary},
* {@link RequestListener#onComplete} 並不會被回調,請區分 {@link #request}。
*
* @param url 服務器地址
* @param params 存放參數的容器
* @param httpMethod "GET" or "POST"
* @param listener 回調對象
*/
public static void request4Binary(
final Context context,
final String url,
final WeiboParameters params,
final String httpMethod,
final RequestListener listener) {
new Thread() {
@Override
public void run() {
try {
ByteArrayOutputStream resp = HttpManager.openUrl4Binary(
context, url, httpMethod, params, params.getValue("pic"));
if (listener != null) {
listener.onComplete4binary(resp);
}
} catch (WeiboException e) {
if (listener != null) {
listener.onError(e);
}
}
}
}.start();
}
示例9: paramToUpload
import com.sina.weibo.sdk.exception.WeiboException; //導入依賴的package包/類
private static void paramToUpload(OutputStream baos, WeiboParameters params)
throws WeiboException {
String key = "";
for (int loc = 0; loc < params.size(); loc++) {
key = params.getKey(loc);
StringBuilder temp = new StringBuilder(10);
temp.setLength(0);
temp.append(MP_BOUNDARY).append("\r\n");
temp.append("content-disposition: form-data; name=\"").append(key).append("\"\r\n\r\n");
temp.append(params.getValue(key)).append("\r\n");
byte[] res = temp.toString().getBytes();
try {
baos.write(res);
} catch (IOException e) {
throw new WeiboException(e);
}
}
}
示例10: getUserInfo
import com.sina.weibo.sdk.exception.WeiboException; //導入依賴的package包/類
public String[] getUserInfo(String uid) throws WeiboException {
String url = API_SERVER + "/users/show.json";
String res = CacheUtils.getCache(
sContext,
CacheUtils.getKey(CacheUtils.CACHE_USER_INFO, new String[] {
"uid", uid }), 3 * 24 * 60 * 60 * 1000);
if (res != null) {
return new String[] { "true", res };
}
WeiboParameters params = new WeiboParameters(Constants.APP_KEY);
params.put("uid", uid);
params.put("access_token", sAccessToken.getToken());
return new String[] { "false",
new AsyncWeiboRunner(sContext).request(url, params, "GET") };
}
示例11: getWeiboInfo
import com.sina.weibo.sdk.exception.WeiboException; //導入依賴的package包/類
public String[] getWeiboInfo(String weiboId) throws WeiboException {
String url = API_SERVER + "/statuses/show.json";
String res = CacheUtils.getCache(
sContext,
CacheUtils.getKey(CacheUtils.CACHE_WEIBO_INFO, new String[] {
"id", weiboId }), 3 * 24 * 60 * 60 * 1000);
if (res != null) {
return new String[] { "true", res };
}
WeiboParameters params = new WeiboParameters(Constants.APP_KEY);
params.put("id", weiboId);
params.put("access_token", sAccessToken.getToken());
return new String[] { "false",
new AsyncWeiboRunner(sContext).request(url, params, "GET") };
}
示例12: doLogin
import com.sina.weibo.sdk.exception.WeiboException; //導入依賴的package包/類
@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();
}
});
}
示例13: allInOneShare
import com.sina.weibo.sdk.exception.WeiboException; //導入依賴的package包/類
private void allInOneShare(final Context context, SendMultiMessageToWeiboRequest request) {
AuthInfo authInfo = new AuthInfo(context, mSinaAppKey, REDIRECT_URL, SCOPE);
Oauth2AccessToken accessToken = AccessTokenKeeper.readAccessToken(context);
String token = "";
if (accessToken != null) {
token = accessToken.getToken();
}
mSinaAPI.sendRequest((Activity) context, request, authInfo, token, new WeiboAuthListener() {
@Override
public void onWeiboException(WeiboException arg0) {
Toast.makeText(context, context.getString(
R.string.share_failed), Toast.LENGTH_SHORT).show();
}
@Override
public void onComplete(Bundle bundle) {
Oauth2AccessToken newToken = Oauth2AccessToken.parseAccessToken(bundle);
AccessTokenKeeper.writeAccessToken(context, newToken);
Toast.makeText(context, context.getString(
R.string.share_success), Toast.LENGTH_SHORT).show();
}
@Override
public void onCancel() {
Toast.makeText(context, context.getString(
R.string.share_cancel), Toast.LENGTH_SHORT).show();
}
});
}
示例14: onWeiboException
import com.sina.weibo.sdk.exception.WeiboException; //導入依賴的package包/類
@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();
}
}
示例15: shareToWeibo
import com.sina.weibo.sdk.exception.WeiboException; //導入依賴的package包/類
/**
* 分享到微博
*
* @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()));
}
});
}