当前位置: 首页>>代码示例>>Java>>正文


Java WeiboAuthListener类代码示例

本文整理汇总了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));
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:20,代码来源:SsoHandler.java

示例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();
        }
    });
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:WeiboLoginInstance.java

示例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();

            }
        });

    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:35,代码来源:WeiboShareManager.java

示例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()));
                    }
                });

    }
 
开发者ID:yangjie127,项目名称:ESSocialSDK-master,代码行数:40,代码来源:SocialShareProxy.java

示例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();

}
 
开发者ID:yangjie127,项目名称:ESSocialSDK-master,代码行数:37,代码来源:WeiboShareProxy.java

示例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);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:9,代码来源:SsoHandler.java

示例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);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:11,代码来源:WeiboSdkBrowser.java

示例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();
        }
    });
}
 
开发者ID:beanu,项目名称:smart-farmer-android,代码行数:30,代码来源:WeiboLoginInstance.java

示例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);
		}
	}
}
 
开发者ID:Joy-Whale,项目名称:EasyShare,代码行数:31,代码来源:SinaWeiboEntryActivity.java

示例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();

            }
        });

    }
 
开发者ID:henjue,项目名称:sharesdk,代码行数:32,代码来源:WeiboShareManager.java

示例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() {
           }
       });
}
 
开发者ID:liuling07,项目名称:QiQuYing,代码行数:39,代码来源:SharePopWindow.java

示例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();
        }
    });
}
 
开发者ID:CyanFlxy,项目名称:KnockKnock,代码行数:40,代码来源:WeiboAuthActivity.java

示例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;
    }
}
 
开发者ID:BruceHurrican,项目名称:asstudydemo,代码行数:32,代码来源:SinaActivity.java

示例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);
    }
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:10,代码来源:SsoHandler.java

示例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());
		}
	});
}
 
开发者ID:minixalpha,项目名称:Webo,代码行数:30,代码来源:LoginActivity.java


注:本文中的com.sina.weibo.sdk.auth.WeiboAuthListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。