本文整理匯總了Java中com.sina.weibo.sdk.auth.WeiboAuthListener類的典型用法代碼示例。如果您正苦於以下問題:Java WeiboAuthListener類的具體用法?Java WeiboAuthListener怎麽用?Java WeiboAuthListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
WeiboAuthListener類屬於com.sina.weibo.sdk.auth包,在下文中一共展示了WeiboAuthListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: authorize
import com.sina.weibo.sdk.auth.WeiboAuthListener; //導入依賴的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));
}
}
}
示例2: doLogin
import com.sina.weibo.sdk.auth.WeiboAuthListener; //導入依賴的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();
}
});
}
示例3: allInOneShare
import com.sina.weibo.sdk.auth.WeiboAuthListener; //導入依賴的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();
}
});
}
示例4: shareToWeibo
import com.sina.weibo.sdk.auth.WeiboAuthListener; //導入依賴的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()));
}
});
}
示例5: shareTo
import com.sina.weibo.sdk.auth.WeiboAuthListener; //導入依賴的package包/類
private static void shareTo(final Context context, final String appKey, final String redirectUrl, final String scop, final String title, final String desc,
final String imageUrl, final String shareUrl, final WeiboAuthListener listener) {
new Thread(new Runnable() {
@Override
public void run() {
WeiboMultiMessage msg = new WeiboMultiMessage();
TextObject text = new TextObject();
text.text = desc;
msg.textObject = text;
WebpageObject web = new WebpageObject();
web.description = desc;
byte[] thumb = SocialUtils.getHtmlByteArray(imageUrl);
if (null != thumb)
web.thumbData = SocialUtils.compressBitmap(thumb, 32);
else
web.thumbData = SocialUtils.compressBitmap(SocialUtils.getDefaultShareImage(context), 32);
web.actionUrl = shareUrl;
web.identify = imageUrl;
web.title = title;
msg.mediaObject = web;
SendMultiMessageToWeiboRequest request = new SendMultiMessageToWeiboRequest();
request.transaction = String.valueOf(System.currentTimeMillis());
request.multiMessage = msg;
AuthInfo authInfo = new AuthInfo(context, appKey, redirectUrl, scop);
Oauth2AccessToken accessToken = AccessTokenKeeper.readAccessToken(context);
String token = "";
if (accessToken != null) {
token = accessToken.getToken();
}
getInstance(context, appKey).sendRequest((Activity) context, request, authInfo, token, listener);
}
}).start();
}
示例6: registerOrLoginByMobile
import com.sina.weibo.sdk.auth.WeiboAuthListener; //導入依賴的package包/類
public void registerOrLoginByMobile(String title, WeiboAuthListener listener) {
this.mAuthListener = listener;
Intent intentTemp = new Intent(this.mAuthActivity, MobileRegisterActivity.class);
Bundle param = this.mAuthInfo.getAuthBundle();
param.putString("register_title", title);
intentTemp.putExtras(param);
this.mAuthActivity.startActivityForResult(intentTemp, REQUEST_CODE_MOBILE_REGISTER);
}
示例7: startAuth
import com.sina.weibo.sdk.auth.WeiboAuthListener; //導入依賴的package包/類
public static void startAuth(Context context, String url, AuthInfo authInfo, WeiboAuthListener listener) {
AuthRequestParam reqParam = new AuthRequestParam(context);
reqParam.setLauncher(BrowserLauncher.AUTH);
reqParam.setUrl(url);
reqParam.setAuthInfo(authInfo);
reqParam.setAuthListener(listener);
Intent intent = new Intent(context, WeiboSdkBrowser.class);
intent.putExtras(reqParam.createRequestParamBundle());
context.startActivity(intent);
}
示例8: doLogin
import com.sina.weibo.sdk.auth.WeiboAuthListener; //導入依賴的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();
}
});
}
示例9: share
import com.sina.weibo.sdk.auth.WeiboAuthListener; //導入依賴的package包/類
private void share() {
SendMultiMessageToWeiboRequest request = new SendMultiMessageToWeiboRequest();
request.transaction = String.valueOf(System.currentTimeMillis());
request.multiMessage = mWeiboMessage;
final String token = getToken();
if (TextUtils.isEmpty(token)) {
handlerSSO();
} else {
// 添加個空的WeiboAuthListener,若不添加,則在分享成功後,倒計時3s後微博分享頁麵不能正常關閉
if (!mShareApi.sendRequest(this, request, mAuthInfo, token, new WeiboAuthListener() {
@Override
public void onComplete(Bundle bundle) {
Logs.d(TAG, bundle.toString());
}
@Override
public void onWeiboException(WeiboException e) {
}
@Override
public void onCancel() {
}
})) {
ShareCallbackReceiver.sendBroadcastError(this, ErrorCode.ERROR_SHARE);
}
}
}
示例10: allInOneShare
import com.sina.weibo.sdk.auth.WeiboAuthListener; //導入依賴的package包/類
private void allInOneShare(final Context context, SendMultiMessageToWeiboRequest request) {
AuthInfo authInfo = new AuthInfo(context, mSinaAppKey, ShareSDK.getInstance().getSinaRedirectUrl(), 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) {
mListener.onFaild();
}
@Override
public void onComplete(Bundle bundle) {
Oauth2AccessToken newToken = Oauth2AccessToken.parseAccessToken(bundle);
AccessTokenKeeper.writeAccessToken(context, newToken);
mListener.onSuccess();
}
@Override
public void onCancel() {
mListener.onCancel();
}
});
}
示例11: share2weibo
import com.sina.weibo.sdk.auth.WeiboAuthListener; //導入依賴的package包/類
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() {
}
});
}
示例12: share
import com.sina.weibo.sdk.auth.WeiboAuthListener; //導入依賴的package包/類
private void share() {
weiboShareAPI = WeiboShareSDK.createWeiboAPI(this, WEIBO_APP_KEY);
weiboShareAPI.registerApp();
WeiboMultiMessage weiboMessage = getShareMessage();
SendMultiMessageToWeiboRequest request = new SendMultiMessageToWeiboRequest();
request.transaction = String.valueOf(System.currentTimeMillis());
request.multiMessage = weiboMessage;
AuthInfo authInfo = new AuthInfo(this, WEIBO_APP_KEY, WEIBO_REDIRECT_URL, WEIBO_SCOPE);
Oauth2AccessToken accessToken = DataSharedPreferences.readAccessToken();
String token = "";
if (accessToken != null) {
token = accessToken.getToken();
}
weiboShareAPI.sendRequest(this, request, authInfo, token, new WeiboAuthListener() {
@Override
public void onWeiboException(WeiboException arg0) {
ShareUtil.shareFail();
finish();
}
@Override
public void onComplete(Bundle bundle) {
Oauth2AccessToken newToken = Oauth2AccessToken.parseAccessToken(bundle);
DataSharedPreferences.writeAccessToken(newToken);
ShareUtil.shareSuccess();
finish();
statistic();
}
@Override
public void onCancel() {
finish();
}
});
}
示例13: onClick
import com.sina.weibo.sdk.auth.WeiboAuthListener; //導入依賴的package包/類
@OnClick({R.id.btn_sina_login, R.id.btn_sina_share})
public void onClick(View view) {
switch (view.getId()) {
case R.id.btn_sina_login:
ssoHandler.authorize(new WeiboAuthListener() {
@Override
public void onComplete(Bundle bundle) {
LogUtils.i("bundle->" + bundle);
accessToken = Oauth2AccessToken.parseAccessToken(bundle);
if (accessToken.isSessionValid()) {
AccessTokenKeeper.writeAccessToken(SinaActivity.this, accessToken);
} else {
}
}
@Override
public void onWeiboException(WeiboException e) {
LogUtils.e("授權失敗->" + e.toString());
}
@Override
public void onCancel() {
LogUtils.i("取消新浪登錄");
}
});
break;
case R.id.btn_sina_share:
break;
}
}
示例14: authorize
import com.sina.weibo.sdk.auth.WeiboAuthListener; //導入依賴的package包/類
public void authorize(int i, WeiboAuthListener weiboauthlistener, String s)
{
mSSOAuthRequestCode = i;
mAuthListener = weiboauthlistener;
if (!bindRemoteSSOService(mAuthActivity.getApplicationContext(), s) && mWeibo != null)
{
mWeibo.anthorize(mAuthListener);
}
}
示例15: requestAuth
import com.sina.weibo.sdk.auth.WeiboAuthListener; //導入依賴的package包/類
private void requestAuth() {
// 創建微博實例
mWeiboAuth = new WeiboAuth(this, Configure.getAppKey(),
Configure.getRedirectURL(), Configure.getScope());
mWeiboAuth.anthorize(new WeiboAuthListener() {
@Override
public void onCancel() {
Log.d(TAG, "cancel auth");
finish();
}
@Override
public void onComplete(Bundle values) {
// 從 Bundle 中解析 Token
mAccessToken = Oauth2AccessToken.parseAccessToken(values);
Utils.saveToken(mAccessToken);
Log.d(TAG, "auth complete");
startMainPage();
}
@Override
public void onWeiboException(WeiboException exception) {
Log.d(TAG, "auth exception" + exception.getMessage());
}
});
}