com.sina.weibo.sdk.api.WeiboMultiMessage Java Examples
The following examples show how to use
com.sina.weibo.sdk.api.WeiboMultiMessage.
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: WeiboShareInstance.java From ShareLoginPayUtil with Apache License 2.0 | 6 votes |
private void handleShare(Pair<String, byte[]> stringPair, String title, String targetUrl , String summary, ShareListener listener) { if (listener != null) { listener.shareStart(); } WeiboMultiMessage message = new WeiboMultiMessage(); if (!TextUtils.isEmpty(summary)) { message.textObject = getTextObj(title, targetUrl, summary); } if (stringPair != null) { message.imageObject = getImageObj(stringPair); } shareHandler.shareMessage(message, false); recycle(); }
Example #2
Source File: SinaShareHandler.java From BiliShare with Apache License 2.0 | 6 votes |
private void allInOneShare(final WeiboMultiMessage weiboMessage) { final String token = getToken(); if (TextUtils.isEmpty(token)) { mWeiboMessage = weiboMessage; Log.d(TAG, "authorize when allInOneShare"); mSsoHandler = new SsoHandler((Activity) getContext()); mSsoHandler.authorize(mAuthListener); } else { mWeiboMessage = null; mSsoHandler = null; doOnMainThread(new Runnable() { @Override public void run() { postProgressStart(); Log.d(TAG, "share message when allInOneShare"); mShareHandler.shareMessage(weiboMessage, false); } }); } }
Example #3
Source File: SinaShareHandler.java From BiliShare with Apache License 2.0 | 6 votes |
/** * Contont and image cannot be empty or null * * @param params * @throws ShareException */ @Override protected void shareWebPage(final ShareParamWebPage params) throws ShareException { checkContent(params); if (TextUtils.isEmpty(params.getTargetUrl())) { throw new InvalidParamException("Target url is empty or illegal"); } doOnWorkThread(new Runnable() { @Override public void run() { final WeiboMultiMessage weiboMessage = new WeiboMultiMessage(); weiboMessage.textObject = getTextObj(params); try { checkImage(params.getThumb()); weiboMessage.imageObject = getImageObj(params.getThumb()); } catch (Exception e) { weiboMessage.textObject = getTextObj(params); } allInOneShare(weiboMessage); } }); }
Example #4
Source File: SinaShareHandler.java From BiliShare with Apache License 2.0 | 6 votes |
/** * Contont and image cannot be empty or null * * @param params * @throws ShareException */ @Override protected void shareImage(final ShareParamImage params) throws ShareException { checkContent(params); checkImage(params.getImage()); doOnWorkThread(new Runnable() { @Override public void run() { final WeiboMultiMessage weiboMessage = new WeiboMultiMessage(); weiboMessage.textObject = getTextObj(params); weiboMessage.imageObject = getImageObj(params.getImage()); allInOneShare(weiboMessage); } }); }
Example #5
Source File: Share.java From UPMiss with GNU General Public License v3.0 | 6 votes |
private static void shareToWeibo(Activity activity, String title, String summary, Bitmap img) { ImageObject imageObject = new ImageObject(); imageObject.imageData = bmpToByteArray(img); TextObject textObject = new TextObject(); textObject.text = title + "\n" + summary + Constants.SUMMARY; WeiboMultiMessage message = new WeiboMultiMessage(); message.textObject = textObject; message.imageObject = imageObject; WbShareHandler wbApi = getWbApi(activity); wbApi.shareMessage(message, false); // Bind cache activity.getWindow().getDecorView().setTag(wbApi); }
Example #6
Source File: WbPlatform.java From SocialSdkLibrary with Apache License 2.0 | 6 votes |
private void shareWeb(int shareTarget, final Activity activity, final ShareObj obj) { BitmapUtil.getStaticSizeBitmapByteByPathTask(obj.getThumbImagePath(), THUMB_IMAGE_SIZE_32) .continueWith(new ThumbTask(TAG, "shareWeb") { @Override public void onSuccess(byte[] thumbData) { WeiboMultiMessage multiMessage = new WeiboMultiMessage(); checkAddTextAndImageObj(multiMessage, obj, thumbData); multiMessage.mediaObject = getWebObj(obj, thumbData); mShareHandler.shareMessage(multiMessage, false); } @Override public void onFail(SocialError error) { onShareFail(error); } }, Task.UI_THREAD_EXECUTOR); }
Example #7
Source File: WbPlatform.java From SocialSdkLibrary with Apache License 2.0 | 6 votes |
private void shareImage(int shareTarget, final Activity activity, final ShareObj obj) { if (FileUtil.isGifFile(obj.getThumbImagePath())) { makeOpenApiShareHelper(activity).post(activity, obj); } else { BitmapUtil.getStaticSizeBitmapByteByPathTask(obj.getThumbImagePath(), THUMB_IMAGE_SIZE_32) .continueWith(new ThumbTask(TAG, "shareImage") { @Override public void onSuccess(byte[] thumbData) { WeiboMultiMessage multiMessage = new WeiboMultiMessage(); multiMessage.imageObject = getImageObj(obj.getThumbImagePath(), thumbData); multiMessage.textObject = getTextObj(obj.getSummary()); mShareHandler.shareMessage(multiMessage, false); } @Override public void onFail(SocialError error) { onShareFail(error); } }, Task.UI_THREAD_EXECUTOR); } }
Example #8
Source File: WBHelper.java From SocialHelper with Apache License 2.0 | 6 votes |
@Override public void share(SocialShareCallback callback, ShareEntity shareInfo) { this.shareCallback = callback; if (baseVerify(callback)) { return; } if (!WbSdk.isWbInstall(activity)) { if (callback != null) { callback.socialError(activity.getString(R.string.social_wb_uninstall)); } return; } initShareLister(shareInfo); shareHandler = new WbShareHandler(activity); shareHandler.registerApp(); WeiboMultiMessage weiboMessage = getShareMessage(shareInfo.getParams()); if (weiboMessage == null) { return; } shareHandler.shareMessage(weiboMessage, false); }
Example #9
Source File: WbShareHandler.java From LoginSharePay with Apache License 2.0 | 6 votes |
private void startWebShare(WeiboMultiMessage message) { Intent webIntent = new Intent(this.context, WbShareTransActivity.class); String appPackage = this.context.getPackageName(); ShareWebViewRequestParam webParam = new ShareWebViewRequestParam(WbSdk.getAuthInfo(), WebRequestType.SHARE, "", 1, "微博分享", (String)null, this.context); webParam.setContext(this.context); webParam.setHashKey(""); webParam.setPackageName(appPackage); Oauth2AccessToken token = AccessTokenKeeper.readAccessToken(this.context); if(token != null && !TextUtils.isEmpty(token.getToken())) { webParam.setToken(token.getToken()); } webParam.setMultiMessage(message); Bundle bundle = new Bundle(); webParam.fillBundle(bundle); webIntent.putExtras(bundle); webIntent.putExtra("startFlag", 0); webIntent.putExtra("startActivity", this.context.getClass().getName()); webIntent.putExtra("startAction", "com.sina.weibo.sdk.action.ACTION_WEIBO_ACTIVITY"); webIntent.putExtra("gotoActivity", "com.sina.weibo.sdk.web.WeiboSdkWebActivity"); this.context.startActivity(webIntent); }
Example #10
Source File: WbShareHandler.java From LoginSharePay with Apache License 2.0 | 6 votes |
private void startClientShare(WeiboMultiMessage message) { Bundle data = new Bundle(); data.putInt("_weibo_command_type", 1); data.putString("_weibo_transaction", String.valueOf(System.currentTimeMillis())); data.putLong("callbackId", 0L); data.putAll(message.toBundle(data)); Intent intent = new Intent(); intent.setClass(this.context, WbShareTransActivity.class); intent.putExtra("startPackage", WeiboAppManager.getInstance(this.context).getWbAppInfo().getPackageName()); intent.putExtra("startAction", "com.sina.weibo.sdk.action.ACTION_WEIBO_ACTIVITY"); intent.putExtra("startFlag", 0); intent.putExtra("startActivity", this.context.getClass().getName()); intent.putExtra("progressColor", this.progressColor); intent.putExtra("progressId", this.progressId); if(data != null) { intent.putExtras(data); } try { this.context.startActivity(intent); } catch (Exception var5) { LogUtil.v("weibo sdk error ", var5.toString()); } }
Example #11
Source File: ShareImpl.java From LoginSharePay with Apache License 2.0 | 6 votes |
@Override protected WeiboMultiMessage buildWeiboMultiMessage(WeiboMessageBody weiboMessageBody) { WeiboMultiMessage msg = new WeiboMultiMessage(); if (weiboMessageBody.getText() != null) msg.textObject = getTextObject(weiboMessageBody); switch (weiboMessageBody.msgType) { case WeiboMessageBody.MSG_WEB: msg.mediaObject = getMediaObject(weiboMessageBody); case WeiboMessageBody.MSG_TEXT_IAMGE: if (weiboMessageBody.getLocalImage() != null) msg.imageObject = getImageObject(weiboMessageBody); if (weiboMessageBody.getImagesPath() != null) msg.multiImageObject = getMultiImageObject(weiboMessageBody); break; case WeiboMessageBody.MSG_VIDEO: if (weiboMessageBody.getVideoPath() != null) msg.videoSourceObject = getVideoObject(weiboMessageBody); break; } return msg; }
Example #12
Source File: SharePresenter.java From the-tech-frontier-app with MIT License | 6 votes |
/** * 分享文章到新浪微博 * * @param title * @param url */ public void share(Activity activity, String title, String url) { WeiboMultiMessage weiboMessage = new WeiboMultiMessage();// 初始化微博的分享消息 TextObject textObject = new TextObject(); textObject.text = "《" + title + "》" + "这篇文章不错, 文章地址 : " + url + "。本文来自: 开发技术前线, http://www.devtf.cn 。"; weiboMessage.textObject = textObject; ImageObject imageObject = new ImageObject(); imageObject.setImageObject(BitmapFactory.decodeResource(activity.getResources(), R.drawable.ic_launcher)); weiboMessage.imageObject = imageObject; SendMultiMessageToWeiboRequest request = new SendMultiMessageToWeiboRequest(); request.transaction = String.valueOf(System.currentTimeMillis()); request.multiMessage = weiboMessage; mWeiboShareAPI.sendRequest(activity, request); // 发送请求消息到微博,唤起微博分享界面 }
Example #13
Source File: VersionCheckHandler.java From MiBandDecompiled with Apache License 2.0 | 6 votes |
public boolean check(Context context, WeiboMultiMessage weibomultimessage) { LogUtil.d("VersionCheckHandler", (new StringBuilder("check WeiboMultiMessage package : ")).append(mPackageName).toString()); ApiUtils.WeiboInfo weiboinfo; if (mPackageName != null && mPackageName.length() != 0) { if ((weiboinfo = ApiUtils.queryWeiboInfoByPackage(context, mPackageName)) != null) { LogUtil.d("VersionCheckHandler", (new StringBuilder("check WeiboMultiMessage WeiboInfo supportApi : ")).append(weiboinfo.supportApi).toString()); if (weiboinfo.supportApi >= 10351) { if (weiboinfo.supportApi < 10352 && weibomultimessage.mediaObject != null && (weibomultimessage.mediaObject instanceof CmdObject)) { weibomultimessage.mediaObject = null; } return true; } } } return false; }
Example #14
Source File: WeiboBaseShareInstance.java From SimpleProject with MIT License | 6 votes |
/** * 多图分享 * @param activity * @param desc * @param url * @param imageList */ private void shareMediaByWeibo(Activity activity, String desc, String url, ArrayList<Uri> imageList) { WeiboMultiMessage multiMessage = new WeiboMultiMessage(); if (!TextUtils.isEmpty(desc)) { TextObject textObject = new TextObject(); textObject.text = desc + " " + url; multiMessage.textObject = textObject; } if (!CollectionUtil.isEmpty(imageList)) { MultiImageObject multiImageObj = new MultiImageObject(); multiImageObj.setImageList(imageList); multiMessage.multiImageObject = multiImageObj; } shareHandler.shareMessage(multiMessage, false); }
Example #15
Source File: WeiboBaseShareInstance.java From SimpleProject with MIT License | 6 votes |
/** * 普通分享,支持文字,链接,图片 注意:微博分享设置title无效,链接应追加在desc后面 * @param activity * @param desc * @param url * @param bitmap */ private void shareMediaByWeibo(Activity activity, String desc, String url, Bitmap bitmap) { WeiboMultiMessage multiMessage = new WeiboMultiMessage(); if (!TextUtils.isEmpty(desc)) { TextObject textObject = new TextObject(); textObject.text = desc + " " + url; multiMessage.textObject = textObject; } if (bitmap != null && !bitmap.isRecycled()) { ImageObject imageObject = new ImageObject(); imageObject.setImageObject(bitmap); multiMessage.imageObject = imageObject; } shareHandler.shareMessage(multiMessage, false); }
Example #16
Source File: SharePopWindow.java From QiQuYing with Apache License 2.0 | 5 votes |
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 #17
Source File: WeiboShareManager.java From sharesdk with Apache License 2.0 | 5 votes |
private void shareMusic(Message.Music message) { WeiboMultiMessage weiboMultiMessage = new WeiboMultiMessage(); weiboMultiMessage.mediaObject = getMusicObj(message); //初始化从第三方到微博的消息请求 // SendMultiMessageToWeiboRequest request = new SendMultiMessageToWeiboRequest(); // request.transaction = ShareUtil.buildTransaction("sinamusic"); // request.multiMessage = weiboMultiMessage; mShareHandler.shareMessage(weiboMultiMessage, false); }
Example #18
Source File: WeiboShareManager.java From sharesdk with Apache License 2.0 | 5 votes |
private void shareWebPage(Message.Web message) { WeiboMultiMessage weiboMultiMessage = new WeiboMultiMessage(); weiboMultiMessage.textObject = getTextObj(message.getDescription()); weiboMultiMessage.imageObject = getImageObj(message.getImage()); // 初始化从第三方到微博的消息请求 // SendMultiMessageToWeiboRequest request = new SendMultiMessageToWeiboRequest(); // // 用transaction唯一标识一个请求 // request.transaction = ShareUtil.buildTransaction("sinawebpage"); // request.multiMessage = weiboMultiMessage; // allInOneShare(mContext, request); mShareHandler.shareMessage(weiboMultiMessage, false); }
Example #19
Source File: WeiboShareManager.java From sharesdk with Apache License 2.0 | 5 votes |
private void sharePicture(Message.Picture message) { WeiboMultiMessage weiboMultiMessage = new WeiboMultiMessage(); weiboMultiMessage.imageObject = getImageObj(message.getImage()); //初始化从第三方到微博的消息请求 // request.transaction = ShareUtil.buildTransaction("sinapic"); // request.multiMessage = weiboMultiMessage; mShareHandler.shareMessage(weiboMultiMessage, false); }
Example #20
Source File: WeiboShareManager.java From sharesdk with Apache License 2.0 | 5 votes |
private void shareText(Message.Text message) { //初始化微博的分享消息 WeiboMultiMessage weiboMultiMessage = new WeiboMultiMessage(); weiboMultiMessage.textObject = getTextObj(message.getContent()); // //初始化从第三方到微博的消息请求 // request.transaction = ShareUtil.buildTransaction("sinatext"); // request.multiMessage = weiboMultiMessage; mShareHandler.shareMessage(weiboMultiMessage, false); }
Example #21
Source File: WeiboShareInstance.java From smart-farmer-android with Apache License 2.0 | 5 votes |
@Override public void shareText(int platform, String text, Activity activity, ShareListener listener) { TextObject textObject = new TextObject(); textObject.text = text; WeiboMultiMessage message = new WeiboMultiMessage(); message.textObject = textObject; sendRequest(activity, message); }
Example #22
Source File: WeiboShareInstance.java From ShareUtil with Apache License 2.0 | 5 votes |
@Override public void shareText(int platform, String text, Activity activity, ShareListener listener) { TextObject textObject = new TextObject(); textObject.text = text; WeiboMultiMessage message = new WeiboMultiMessage(); message.textObject = textObject; sendRequest(activity, message); }
Example #23
Source File: WeiboShareProxy.java From ESSocialSDK with Apache License 2.0 | 5 votes |
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(); }
Example #24
Source File: SinaShareHandler.java From BiliShare with Apache License 2.0 | 5 votes |
@Override protected void shareVideo(final ShareParamVideo params) throws ShareException { checkContent(params); if (TextUtils.isEmpty(params.getTargetUrl())) { throw new InvalidParamException("Target url is empty or illegal"); } if (params.getVideo() == null) { throw new InvalidParamException("Video is empty or illegal"); } doOnWorkThread(new Runnable() { @Override public void run() { final WeiboMultiMessage weiboMessage = new WeiboMultiMessage(); weiboMessage.textObject = getTextObj(params); try { checkImage(params.getThumb()); weiboMessage.imageObject = getImageObj(params.getThumb()); } catch (Exception e) { weiboMessage.textObject = getTextObj(params); } allInOneShare(weiboMessage); } }); }
Example #25
Source File: WBShare.java From sdk3rd with Apache License 2.0 | 5 votes |
@Override public void share(@NonNull final ShareData data, @NonNull final OnCallback<String> callback) { // if (!mApi.isWeiboAppInstalled()) { // callback.onFailed(mActivity, ResultCode.RESULT_FAILED, "您未安装微博!"); // return; // } WeiboMultiMessage message = new WeiboMultiMessage(); if (data.hasText()) { message.textObject = toText(data.hasUrl() ? (data.text + " " + data.url) : data.text); } if (data.media instanceof MoImage) { message.imageObject = toImage(((MoImage) data.media).resource); } if (message.textObject == null && message.imageObject == null) { // unsupported callback.onFailed(mActivity, ResultCode.RESULT_FAILED, "不支持的分享类型"); return; } mCallback = callback; mCallback.onStarted(mActivity); mApi.shareMessage(message, true); }
Example #26
Source File: SinaShareHandler.java From BiliShare with Apache License 2.0 | 5 votes |
@Override protected void shareAudio(final ShareParamAudio params) throws ShareException { checkContent(params); if (TextUtils.isEmpty(params.getTargetUrl())) { throw new InvalidParamException("Target url is empty or illegal"); } if (params.getAudio() == null) { throw new InvalidParamException("Audio is empty or illegal"); } doOnWorkThread(new Runnable() { @Override public void run() { final WeiboMultiMessage weiboMessage = new WeiboMultiMessage(); weiboMessage.textObject = getTextObj(params); try { checkImage(params.getThumb()); weiboMessage.imageObject = getImageObj(params.getThumb()); } catch (Exception e) { weiboMessage.textObject = getTextObj(params); } allInOneShare(weiboMessage); } }); }
Example #27
Source File: WbShareHandler.java From LoginSharePay with Apache License 2.0 | 5 votes |
public void shareMessage(WeiboMultiMessage message, boolean clientOnly) { if(!this.hasRegister) { throw new RuntimeException("please call WbShareHandler.registerApp(),before use share function"); } else if(WbSdk.isWbInstall(this.context) || !clientOnly) { if(!clientOnly && !WbSdk.isWbInstall(this.context)) { this.startWebShare(message); } else { this.startClientShare(message); } } }
Example #28
Source File: SinaShareHandler.java From BiliShare with Apache License 2.0 | 5 votes |
/** * Contont cannot be empty * * @param params * @throws ShareException */ @Override protected void shareText(final ShareParamText params) throws ShareException { checkContent(params); final WeiboMultiMessage weiboMessage = new WeiboMultiMessage(); weiboMessage.textObject = getTextObj(params); allInOneShare(weiboMessage); }
Example #29
Source File: WBHelper.java From SocialHelper with Apache License 2.0 | 5 votes |
private WeiboMultiMessage getShareMessage(Bundle params) { WeiboMultiMessage msg = new WeiboMultiMessage(); int type = params.getInt(WBShareEntity.KEY_WB_TYPE); BaseMediaObject mediaObject = null; switch (type) { case WBShareEntity.TYPE_TEXT: msg.textObject = getTextObj(params); mediaObject = msg.textObject; break; case WBShareEntity.TYPE_IMG_TEXT: msg.imageObject = getImageObj(params); msg.textObject = getTextObj(params); mediaObject = msg.imageObject; break; case WBShareEntity.TYPE_MULTI_IMAGES: msg.multiImageObject = getMultiImgObj(params); msg.textObject = getTextObj(params); mediaObject = msg.multiImageObject; break; case WBShareEntity.TYPE_VIDEO: msg.videoSourceObject = getVideoObj(params); msg.textObject = getTextObj(params); mediaObject = msg.videoSourceObject; break; case WBShareEntity.TYPE_WEB: msg.mediaObject = getWebPageObj(params); msg.textObject = getTextObj(params); mediaObject = msg.mediaObject; break; } if (mediaObject == null) { return null; } return msg; }
Example #30
Source File: WbPlatform.java From SocialSdkLibrary with Apache License 2.0 | 5 votes |
private void shareVideo(int shareTarget, final Activity activity, final ShareObj obj) { String mediaPath = obj.getMediaPath(); if (FileUtil.isExist(mediaPath)) { WeiboMultiMessage multiMessage = new WeiboMultiMessage(); checkAddTextAndImageObj(multiMessage, obj, null); multiMessage.videoSourceObject = getVideoObj(obj, null); mShareHandler.shareMessage(multiMessage, false); } else { shareWeb(shareTarget, activity, obj); } }