com.sina.weibo.sdk.utils.Utility Java Examples
The following examples show how to use
com.sina.weibo.sdk.utils.Utility.
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: SsoHandler.java From letv with Apache License 2.0 | 6 votes |
private boolean startSingleSignOn(String ssoPackageName, String ssoActivityName) { boolean bSucceed = true; Intent intent = new Intent(); intent.setClassName(ssoPackageName, ssoActivityName); intent.putExtras(this.mWebAuthHandler.getAuthInfo().getAuthBundle()); intent.putExtra("_weibo_command_type", 3); intent.putExtra("_weibo_transaction", String.valueOf(System.currentTimeMillis())); intent.putExtra("aid", Utility.getAid(this.mAuthActivity, this.mAuthInfo.getAppKey())); if (!SecurityHelper.validateAppSignatureForIntent(this.mAuthActivity, intent)) { return false; } String aid = Utility.getAid(this.mAuthActivity, this.mAuthInfo.getAppKey()); if (!TextUtils.isEmpty(aid)) { intent.putExtra("aid", aid); } try { this.mAuthActivity.startActivityForResult(intent, this.mSSOAuthRequestCode); } catch (ActivityNotFoundException e) { bSucceed = false; } return bSucceed; }
Example #2
Source File: WbShareHandler.java From LoginSharePay with Apache License 2.0 | 6 votes |
private void sendBroadcast(Context context, String action, String key, String packageName, Bundle data) { Intent intent = new Intent(action); String appPackage = context.getPackageName(); intent.putExtra("_weibo_sdkVersion", "0041005000"); intent.putExtra("_weibo_appPackage", appPackage); intent.putExtra("_weibo_appKey", key); intent.putExtra("_weibo_flag", 538116905); intent.putExtra("_weibo_sign", MD5.hexdigest(Utility.getSign(context, appPackage))); if(!TextUtils.isEmpty(packageName)) { intent.setPackage(packageName); } if(data != null) { intent.putExtras(data); } context.sendBroadcast(intent, "com.sina.weibo.permission.WEIBO_SDK_PERMISSION"); }
Example #3
Source File: WeiboShareAPIImpl.java From MiBandDecompiled with Apache License 2.0 | 6 votes |
private void sendBroadcast(Context context, String s, String s1, String s2, Bundle bundle) { Intent intent = new Intent(s); String s3 = context.getPackageName(); intent.putExtra("_weibo_sdkVersion", 22); intent.putExtra("_weibo_appPackage", s3); intent.putExtra("_weibo_appKey", s1); intent.putExtra("_weibo_flag", 0x20130329); intent.putExtra("_weibo_sign", MD5.hexdigest(Utility.getSign(context, s3))); if (!TextUtils.isEmpty(s2)) { intent.setPackage(s2); } if (bundle != null) { intent.putExtras(bundle); } LogUtil.d("WeiboApiImpl", (new StringBuilder("intent=")).append(intent).append(", extra=").append(intent.getExtras()).toString()); context.sendBroadcast(intent, "com.sina.weibo.permission.WEIBO_SDK_PERMISSION"); }
Example #4
Source File: LoginShare.java From LoginSharePay with Apache License 2.0 | 6 votes |
@Override protected WebpageObject getMediaObject(WeiboMessageBody weiboMessageBody) { WebpageObject mediaObject = new WebpageObject(); mediaObject.identify = Utility.generateGUID(); mediaObject.title = weiboMessageBody.getTitle(); mediaObject.description = weiboMessageBody.getDescription(); // 设置 Bitmap 类型的图片到视频对象里 设置缩略图。 注意:最终压缩过的缩略图大小不得超过 32kb。 Bitmap bmp = BitmapFactory.decodeFile(weiboMessageBody.getLocalImage()); Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp, Util.THUMB_SIZE, Util.THUMB_SIZE, true); if (!bmp.equals(thumbBmp)) bmp.recycle(); mediaObject.setThumbImage(thumbBmp); mediaObject.actionUrl = weiboMessageBody.getActionUrl(); mediaObject.defaultText = "Webpage 默认文案"; return mediaObject; }
Example #5
Source File: WeiboDialog.java From MiBandDecompiled with Apache License 2.0 | 6 votes |
private void handleRedirectUrl(String s) { Bundle bundle = Utility.parseUrl(s); String s1 = bundle.getString("error"); String s2 = bundle.getString("error_code"); String s3 = bundle.getString("error_description"); if (s1 == null && s2 == null) { mListener.onComplete(bundle); return; } else { mListener.onWeiboException(new WeiboAuthException(s2, s1, s3)); return; } }
Example #6
Source File: WeiboSdkBrowser.java From letv with Apache License 2.0 | 6 votes |
@SuppressLint({"SetJavaScriptEnabled"}) private void initWebView() { this.mWebView.getSettings().setJavaScriptEnabled(true); if (isWeiboShareRequestParam(this.mRequestParam)) { this.mWebView.getSettings().setUserAgentString(Utility.generateUA(this)); } this.mWebView.getSettings().setSavePassword(false); this.mWebView.setWebViewClient(this.mWeiboWebViewClient); this.mWebView.setWebChromeClient(new WeiboChromeClient()); this.mWebView.requestFocus(); this.mWebView.setScrollBarStyle(0); if (VERSION.SDK_INT >= 11) { this.mWebView.removeJavascriptInterface("searchBoxJavaBridge_"); } else { removeJavascriptInterface(this.mWebView); } }
Example #7
Source File: ShareRequestParam.java From letv with Apache License 2.0 | 6 votes |
public String buildUrl(String picid) { Builder builder = Uri.parse(SHARE_URL).buildUpon(); builder.appendQueryParameter("title", this.mShareContent); builder.appendQueryParameter("version", "0031105000"); if (!TextUtils.isEmpty(this.mAppKey)) { builder.appendQueryParameter("source", this.mAppKey); } if (!TextUtils.isEmpty(this.mToken)) { builder.appendQueryParameter("access_token", this.mToken); } String aid = Utility.getAid(this.mContext, this.mAppKey); if (!TextUtils.isEmpty(aid)) { builder.appendQueryParameter("aid", aid); } if (!TextUtils.isEmpty(this.mAppPackage)) { builder.appendQueryParameter(REQ_PARAM_PACKAGENAME, this.mAppPackage); } if (!TextUtils.isEmpty(this.mHashKey)) { builder.appendQueryParameter(REQ_PARAM_KEY_HASH, this.mHashKey); } if (!TextUtils.isEmpty(picid)) { builder.appendQueryParameter(REQ_PARAM_PICINFO, picid); } return builder.build().toString(); }
Example #8
Source File: ShareRequestParam.java From letv with Apache License 2.0 | 6 votes |
public void onCreateRequestParamBundle(Bundle data) { if (this.mBaseRequest != null) { this.mBaseRequest.toBundle(data); } if (!TextUtils.isEmpty(this.mAppPackage)) { this.mHashKey = MD5.hexdigest(Utility.getSign(this.mContext, this.mAppPackage)); } data.putString("access_token", this.mToken); data.putString("source", this.mAppKey); data.putString(REQ_PARAM_PACKAGENAME, this.mAppPackage); data.putString(REQ_PARAM_KEY_HASH, this.mHashKey); data.putString("_weibo_appPackage", this.mAppPackage); data.putString("_weibo_appKey", this.mAppKey); data.putInt("_weibo_flag", 538116905); data.putString("_weibo_sign", this.mHashKey); if (this.mAuthListener != null) { WeiboCallbackManager manager = WeiboCallbackManager.getInstance(this.mContext); this.mAuthListenerKey = manager.genCallbackKey(); manager.setWeiboAuthListener(this.mAuthListenerKey, this.mAuthListener); data.putString(AuthRequestParam.EXTRA_KEY_LISTENER, this.mAuthListenerKey); } }
Example #9
Source File: WidgetRequestParam.java From letv with Apache License 2.0 | 6 votes |
public void onCreateRequestParamBundle(Bundle data) { this.mAppPackage = this.mContext.getPackageName(); if (!TextUtils.isEmpty(this.mAppPackage)) { this.mHashKey = MD5.hexdigest(Utility.getSign(this.mContext, this.mAppPackage)); } data.putString("access_token", this.mToken); data.putString("source", this.mAppKey); data.putString(ShareRequestParam.REQ_PARAM_PACKAGENAME, this.mAppPackage); data.putString(ShareRequestParam.REQ_PARAM_KEY_HASH, this.mHashKey); data.putString(REQ_PARAM_ATTENTION_FUID, this.mAttentionFuid); data.putString(REQ_PARAM_COMMENT_TOPIC, this.mCommentTopic); data.putString(REQ_PARAM_COMMENT_CONTENT, this.mCommentContent); data.putString(REQ_PARAM_COMMENT_CATEGORY, this.mCommentCategory); WeiboCallbackManager manager = WeiboCallbackManager.getInstance(this.mContext); if (this.mAuthListener != null) { this.mAuthListenerKey = manager.genCallbackKey(); manager.setWeiboAuthListener(this.mAuthListenerKey, this.mAuthListener); data.putString(AuthRequestParam.EXTRA_KEY_LISTENER, this.mAuthListenerKey); } if (this.mWidgetRequestCallback != null) { this.mWidgetRequestCallbackKey = manager.genCallbackKey(); manager.setWidgetRequestCallback(this.mWidgetRequestCallbackKey, this.mWidgetRequestCallback); data.putString(EXTRA_KEY_WIDGET_CALLBACK, this.mWidgetRequestCallbackKey); } }
Example #10
Source File: ShareWeiboWebViewClient.java From letv with Apache License 2.0 | 6 votes |
public boolean shouldOverrideUrlLoading(WebView view, String url) { if (this.mCallBack != null) { this.mCallBack.shouldOverrideUrlLoadingCallBack(view, url); } if (!url.startsWith(WeiboSdkBrowser.BROWSER_CLOSE_SCHEME)) { return super.shouldOverrideUrlLoading(view, url); } Bundle bundle = Utility.parseUri(url); if (!(bundle.isEmpty() || this.mListener == null)) { this.mListener.onComplete(bundle); } String errCode = bundle.getString("code"); String errMsg = bundle.getString("msg"); if (TextUtils.isEmpty(errCode)) { this.mShareRequestParam.sendSdkCancleResponse(this.mAct); } else if ("0".equals(errCode)) { this.mShareRequestParam.sendSdkOkResponse(this.mAct); } else { this.mShareRequestParam.sendSdkErrorResponse(this.mAct, errMsg); } WeiboSdkBrowser.closeBrowser(this.mAct, this.mShareRequestParam.getAuthListenerKey(), null); return true; }
Example #11
Source File: WidgetWeiboWebViewClient.java From letv with Apache License 2.0 | 6 votes |
public boolean shouldOverrideUrlLoading(WebView view, String url) { if (this.mCallBack != null) { this.mCallBack.shouldOverrideUrlLoadingCallBack(view, url); } boolean needClose = url.startsWith(WeiboSdkBrowser.BROWSER_CLOSE_SCHEME); if (!url.startsWith(WeiboSdkBrowser.BROWSER_CLOSE_SCHEME) && !url.startsWith(WeiboSdkBrowser.BROWSER_WIDGET_SCHEME)) { return super.shouldOverrideUrlLoading(view, url); } Bundle bundle = Utility.parseUri(url); if (!(bundle.isEmpty() || this.mListener == null)) { this.mListener.onComplete(bundle); } if (this.mWidgetCallback != null) { this.mWidgetCallback.onWebViewResult(url); } if (needClose) { WeiboSdkBrowser.closeBrowser(this.mAct, this.mWidgetRequestParam.getAuthListenerKey(), this.mWidgetRequestParam.getWidgetRequestCallbackKey()); } return true; }
Example #12
Source File: WeiboAuth.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
private void startDialog(WeiboAuthListener weiboauthlistener, int i) { if (weiboauthlistener == null) { return; } LinkedHashMap linkedhashmap = new LinkedHashMap(); linkedhashmap.put("client_id", mAuthInfo.mAppKey); linkedhashmap.put("redirect_uri", mAuthInfo.mRedirectUrl); linkedhashmap.put("scope", mAuthInfo.mScope); linkedhashmap.put("response_type", "code"); linkedhashmap.put("display", "mobile"); if (1 == i) { linkedhashmap.put("packagename", mAuthInfo.mPackageName); linkedhashmap.put("key_hash", mAuthInfo.mKeyHash); } String s = (new StringBuilder("https://open.weibo.cn/oauth2/authorize?")).append(Utility.packUrl(linkedhashmap)).toString(); if (!NetworkHelper.hasInternetPermission(mContext)) { UIUtils.showAlert(mContext, "Error", "Application requires permission to access the Internet"); return; } if (NetworkHelper.isNetworkAvailable(mContext)) { (new WeiboDialog(mContext, s, weiboauthlistener, this)).show(); return; } else { String s1 = ResourceManager.getString(mContext, 2); LogUtil.i("Weibo_web_login", (new StringBuilder("String: ")).append(s1).toString()); UIUtils.showToast(mContext, s1, 0); return; } }
Example #13
Source File: WeiboShareAPIImpl.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
private boolean shareWithWeibo(Activity activity, String s, String s1, String s2, Bundle bundle) { if (activity == null || TextUtils.isEmpty(s) || TextUtils.isEmpty(s1) || TextUtils.isEmpty(s2)) { LogUtil.e("ActivityHandler", "send fail, invalid arguments"); return false; } Intent intent = new Intent(); intent.setPackage(s1); intent.setAction(s); String s3 = activity.getPackageName(); intent.putExtra("_weibo_sdkVersion", 22); intent.putExtra("_weibo_appPackage", s3); intent.putExtra("_weibo_appKey", s2); intent.putExtra("_weibo_flag", 0x20130329); intent.putExtra("_weibo_sign", MD5.hexdigest(Utility.getSign(activity, s3))); if (bundle != null) { intent.putExtras(bundle); } try { LogUtil.d("WeiboApiImpl", (new StringBuilder("intent=")).append(intent).append(", extra=").append(intent.getExtras()).toString()); activity.startActivityForResult(intent, 765); } catch (ActivityNotFoundException activitynotfoundexception) { LogUtil.e("WeiboApiImpl", "Failed, target ActivityNotFound"); return false; } return true; }
Example #14
Source File: WBShare.java From sdk3rd with Apache License 2.0 | 5 votes |
WebpageObject toWeb(ShareData data) { WebpageObject mo = new WebpageObject(); mo.identify = Utility.generateGUID(); mo.title = data.title; mo.description = data.description; // Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_logo); // 设置 Bitmap 类型的图片到视频对象里 设置缩略图。 注意:最终压缩过的缩略图大小不得超过 32kb。 mo.setThumbImage(data.thumb.toBitmap()); mo.actionUrl = data.url; mo.defaultText = "Webpage 默认文案"; return mo; }
Example #15
Source File: WeiboDownloader.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
public static Dialog createDownloadConfirmDialog(final Context context, final IWeiboDownloadListener listener) { String s = "\u63D0\u793A"; String s1 = "\u672A\u5B89\u88C5\u5FAE\u535A\u5BA2\u6237\u7AEF\uFF0C\u662F\u5426\u73B0\u5728\u53BB\u4E0B\u8F7D\uFF1F"; String s2 = "\u73B0\u5728\u4E0B\u8F7D"; String s3 = "\u4EE5\u540E\u518D\u8BF4"; if (!Utility.isChineseLocale(context.getApplicationContext())) { s = "Notice"; s1 = "Sina Weibo client is not installed, download now?"; s2 = "Download Now"; s3 = "Download Later"; } return (new android.app.AlertDialog.Builder(context)).setMessage(s1).setTitle(s).setPositiveButton(s2, new _cls1()).setNegativeButton(s3, new _cls2()).create(); }
Example #16
Source File: WeiboAuth.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
public AuthInfo(Context context, String s, String s1, String s2) { mAppKey = ""; mRedirectUrl = ""; mScope = ""; mPackageName = ""; mKeyHash = ""; mBundle = null; mAppKey = s; mRedirectUrl = s1; mScope = s2; mPackageName = context.getPackageName(); mKeyHash = Utility.getSign(context, mPackageName); initAuthBundle(); }
Example #17
Source File: SharePopWindow.java From QiQuYing with Apache License 2.0 | 5 votes |
/** * 创建多媒体(网页)消息对象。 * * @return 多媒体(网页)消息对象。 */ private WebpageObject getWebpageObj() { WebpageObject mediaObject = new WebpageObject(); mediaObject.identify = Utility.generateGUID(); mediaObject.title = ""; mediaObject.description = ""; // 设置 Bitmap 类型的图片到视频对象里 mediaObject.setThumbImage(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher)); mediaObject.actionUrl = targetUrl + mJoke.getId(); mediaObject.schema = ""; return mediaObject; }
Example #18
Source File: AuthInfo.java From Simpler with Apache License 2.0 | 5 votes |
public AuthInfo(Context context, String appKey, String redirectUrl, String scope, String packageName) { super(context, appKey, redirectUrl, scope); this.mAppKey = appKey; this.mRedirectUrl = redirectUrl; this.mScope = scope; this.mPackageName = packageName; this.mKeyHash = Utility.getSign(context, this.mPackageName); }
Example #19
Source File: WbPlatform.java From SocialSdkLibrary with Apache License 2.0 | 5 votes |
private VideoSourceObject getVideoObj(ShareObj obj, byte[] thumbData) { VideoSourceObject mediaObject = new VideoSourceObject(); mediaObject.videoPath = Uri.fromFile(new File(obj.getMediaPath())); mediaObject.identify = Utility.generateGUID(); mediaObject.title = obj.getTitle(); mediaObject.description = obj.getSummary(); // 注意:最终压缩过的缩略图大小不得超过 32kb。 // mediaObject.thumbData = thumbData; mediaObject.actionUrl = obj.getTargetUrl(); mediaObject.during = obj.getDuration() == 0 ? 10 : obj.getDuration(); return mediaObject; }
Example #20
Source File: WbPlatform.java From SocialSdkLibrary with Apache License 2.0 | 5 votes |
private WebpageObject getWebObj(ShareObj obj, byte[] thumbData) { WebpageObject mediaObject = new WebpageObject(); mediaObject.identify = Utility.generateGUID(); mediaObject.title = obj.getTitle(); mediaObject.description = obj.getSummary(); // 注意:最终压缩过的缩略图大小不得超过 32kb。 mediaObject.thumbData = thumbData; mediaObject.actionUrl = obj.getTargetUrl(); mediaObject.defaultText = obj.getSummary(); return mediaObject; }
Example #21
Source File: WBHelper.java From SocialHelper with Apache License 2.0 | 5 votes |
private WebpageObject getWebPageObj(Bundle params) { WebpageObject webpageObject = new WebpageObject(); webpageObject.identify = Utility.generateGUID(); webpageObject.actionUrl = params.getString(WBShareEntity.KEY_WB_WEB_URL); if (addTitleSummaryAndThumb(webpageObject, params)) { return null; } return webpageObject; }
Example #22
Source File: BaseHandler.java From LoginSharePay with Apache License 2.0 | 5 votes |
public void authorizeCallBack(int requestCode, int resultCode, Intent data) { if ('胍' == requestCode) { if (resultCode == -1) { if (!SecurityHelper.checkResponseAppLegal(this.mAuthFragment.getContext(), WeiboAppManager.getInstance(this.mAuthFragment.getContext()).getWbAppInfo(), data)) { this.authListener.onFailure(new WbConnectErrorMessage("your install weibo app is counterfeit", "8001")); return; } String error = Utility.safeString(data.getStringExtra("error")); String error_type = Utility.safeString(data.getStringExtra("error_type")); String error_description = Utility.safeString(data.getStringExtra("error_description")); LogUtil.d("WBAgent", "error: " + error + ", error_type: " + error_type + ", error_description: " + error_description); if (TextUtils.isEmpty(error) && TextUtils.isEmpty(error_type) && TextUtils.isEmpty(error_description)) { Bundle bundle = data.getExtras(); Oauth2AccessToken accessToken = Oauth2AccessToken.parseAccessToken(bundle); if (accessToken != null && accessToken.isSessionValid()) { LogUtil.d("WBAgent", "Login Success! " + accessToken.toString()); AccessTokenKeeper.writeAccessToken(this.mAuthFragment.getContext(), accessToken); this.authListener.onSuccess(accessToken); } } else if (!"access_denied".equals(error) && !"OAuthAccessDeniedException".equals(error)) { LogUtil.d("WBAgent", "Login failed: " + error); this.authListener.onFailure(new WbConnectErrorMessage(error_type, error_description)); } else { LogUtil.d("WBAgent", "Login canceled by user."); this.authListener.cancel(); } } else if (resultCode == 0) { if (data != null) { this.authListener.cancel(); } else { this.authListener.cancel(); } } } }
Example #23
Source File: BaseHandler.java From LoginSharePay with Apache License 2.0 | 5 votes |
protected void startClientAuth(int requestCode) { try { WbAppInfo wbAppInfo = WeiboAppManager.getInstance(this.mAuthFragment.getContext()).getWbAppInfo(); Intent intent = new Intent(); intent.setClassName(wbAppInfo.getPackageName(), wbAppInfo.getAuthActivityName()); intent.putExtras(WbSdk.getAuthInfo().getAuthBundle()); intent.putExtra("_weibo_command_type", 3); intent.putExtra("_weibo_transaction", String.valueOf(System.currentTimeMillis())); intent.putExtra("aid", Utility.getAid(this.mAuthFragment.getContext(), WbSdk.getAuthInfo().getAppKey())); if (!SecurityHelper.validateAppSignatureForIntent(this.mAuthFragment.getContext(), intent)) { return; } this.fillExtraIntent(intent, requestCode); try { this.mAuthFragment.startActivityForResult(intent, this.ssoRequestCode); } catch (Exception var5) { if (this.authListener != null) { this.authListener.onFailure(new WbConnectErrorMessage()); } this.couldNotStartWbSsoActivity(); } } catch (Exception var6) { ; } }
Example #24
Source File: AuthWeiboWebViewClient.java From letv with Apache License 2.0 | 5 votes |
private void handleRedirectUrl(String url) { Bundle values = Utility.parseUrl(url); String errorType = values.getString(NativeProtocol.BRIDGE_ARG_ERROR_BUNDLE); String errorCode = values.getString(NativeProtocol.BRIDGE_ARG_ERROR_CODE); String errorDescription = values.getString(NativeProtocol.BRIDGE_ARG_ERROR_DESCRIPTION); if (errorType == null && errorCode == null) { if (this.mListener != null) { this.mListener.onComplete(values); } } else if (this.mListener != null) { this.mListener.onWeiboException(new WeiboAuthException(errorCode, errorType, errorDescription)); } }
Example #25
Source File: WidgetRequestParam.java From letv with Apache License 2.0 | 5 votes |
private String buildUrl(String baseUrl) { Builder builder = Uri.parse(baseUrl).buildUpon(); builder.appendQueryParameter("version", "0031105000"); if (!TextUtils.isEmpty(this.mAppKey)) { builder.appendQueryParameter("source", this.mAppKey); } if (!TextUtils.isEmpty(this.mToken)) { builder.appendQueryParameter("access_token", this.mToken); } String aid = Utility.getAid(this.mContext, this.mAppKey); if (!TextUtils.isEmpty(aid)) { builder.appendQueryParameter("aid", aid); } if (!TextUtils.isEmpty(this.mAppPackage)) { builder.appendQueryParameter(ShareRequestParam.REQ_PARAM_PACKAGENAME, this.mAppPackage); } if (!TextUtils.isEmpty(this.mHashKey)) { builder.appendQueryParameter(ShareRequestParam.REQ_PARAM_KEY_HASH, this.mHashKey); } if (!TextUtils.isEmpty(this.mAttentionFuid)) { builder.appendQueryParameter(REQ_PARAM_ATTENTION_FUID, this.mAttentionFuid); } if (!TextUtils.isEmpty(this.mCommentTopic)) { builder.appendQueryParameter(REQ_PARAM_COMMENT_TOPIC, this.mCommentTopic); } if (!TextUtils.isEmpty(this.mCommentContent)) { builder.appendQueryParameter(REQ_PARAM_COMMENT_CONTENT, this.mCommentContent); } if (!TextUtils.isEmpty(this.mCommentCategory)) { builder.appendQueryParameter(REQ_PARAM_COMMENT_CATEGORY, this.mCommentCategory); } return builder.build().toString(); }
Example #26
Source File: AuthInfo.java From letv with Apache License 2.0 | 5 votes |
public AuthInfo(Context context, String appKey, String redirectUrl, String scope) { this.mAppKey = appKey; this.mRedirectUrl = redirectUrl; this.mScope = scope; this.mPackageName = context.getPackageName(); this.mKeyHash = Utility.getSign(context, this.mPackageName); }
Example #27
Source File: BaseHandler.java From LoginSharePay with Apache License 2.0 | 4 votes |
protected void startWebAuth() { AuthInfo authInfo = WbSdk.getAuthInfo(); WeiboParameters requestParams = new WeiboParameters(authInfo.getAppKey()); requestParams.put("client_id", authInfo.getAppKey()); requestParams.put("redirect_uri", authInfo.getRedirectUrl()); requestParams.put("scope", authInfo.getScope()); requestParams.put("response_type", "code"); requestParams.put("version", "0041005000"); requestParams.put("luicode", "10000360"); Oauth2AccessToken token = AccessTokenKeeper.readAccessToken(this.mAuthFragment.getContext()); if (token != null && !TextUtils.isEmpty(token.getToken())) { requestParams.put("trans_token", token.getToken()); requestParams.put("trans_access_token", token.getToken()); } requestParams.put("lfid", "OP_" + authInfo.getAppKey()); String aid = Utility.getAid(this.mAuthFragment.getContext(), authInfo.getAppKey()); if (!TextUtils.isEmpty(aid)) { requestParams.put("aid", aid); } requestParams.put("packagename", authInfo.getPackageName()); requestParams.put("key_hash", authInfo.getKeyHash()); String url = "https://open.weibo.cn/oauth2/authorize?" + requestParams.encodeUrl(); if (!NetworkHelper.hasInternetPermission(this.mAuthFragment.getContext())) { UIUtils.showAlert(this.mAuthFragment.getContext(), "Error", "Application requires permission to access the Internet"); } else { String mAuthListenerKey = null; if (this.authListener != null) { WeiboCallbackManager manager = WeiboCallbackManager.getInstance(); mAuthListenerKey = manager.genCallbackKey(); manager.setWeiboAuthListener(mAuthListenerKey, this.authListener); } AuthWebViewRequestParam param = new AuthWebViewRequestParam(authInfo, WebRequestType.AUTH, mAuthListenerKey, "微博登录", url, this.mAuthFragment.getContext()); Intent intent = new Intent(this.mAuthFragment.getContext(), WeiboSdkWebActivity.class); Bundle bundle = new Bundle(); param.fillBundle(bundle); intent.putExtras(bundle); this.mAuthFragment.startActivity(intent); } }