如何在安卓设备上使用Twitter Kit 3分享视频到Twitter?

4

在去除面料后,现在Android中使用Twitter Kit 3。

案例:

  • I need share the text , image and video without opening the Twitter Composer

  • I am sharing the text , image and the video using twitter kit 3 by using the method StatusesService

  • So i can share the text by using below code :

    final TwitterSession session = TwitterCore.getInstance().getSessionManager().getActiveSession();
    StatusesService statusesService = TwitterCore.getInstance().getApiClient(session).getStatusesService();
    statusesService.update("Click this link "+getShareLink(),null,null,null,null,null,null,null,null).enqueue(new Callback<Tweet>() {
        @Override
        public void success(Result<Tweet> result) {
            Toast.makeText(context,"Tweet success ",Toast.LENGTH_SHORT).show();
            Log.e(TAG,"Twitter "+ result.data.toString());
        }
    
        @Override
        public void failure(TwitterException exception) {
            Toast.makeText(context,"Tweet failure ",Toast.LENGTH_SHORT).show();
            Log.e(TAG,"Twitter "+ exception.getMessage());
        }
    });
    
  • For image upload we can use MediaService and for uploading it we can use MediaService.upload() method , but in the MediaServicethey are only prompt the images to upload and i also checked their docs .

  • And now How to share Video in the Twitter kit 3 using StatuesServices or any other method ?

2个回答

3

1)本机视频上传支持仅适用于iOS(请参见附件部分)

2)快速的不完美解决方案 您可以将视频转换为gif格式并上传。

3)正确解决方案:

您可以扩展工具包,使用媒体/上传端点

请查看此帖子请求。


是的,这是正确的。我已经通过Twitter4j完成了它,但不幸的是在扩展Twitter SDK时它无法工作,因为INIT和APPEND是正常的,但在FINALIZE步骤之前检查状态时,它会抛出错误@Optional。 - Ko Vartthan
什么错误?你能分享你的JSON有效载荷和响应吗? - Optional
你通过扩展 Android 上的 Twitter Kit 完成了吗? - Ko Vartthan
1
公平地说,不是。但我已经看到它被扩展和实现了,而且没有使用Composer Api。 - Optional
1
是的 @optional 但它有问题。 - Ko Vartthan
1
走得好。干杯 @KoVartthan - Optional

0

它正在tweet-composer:3.3.0上工作。

我只是将视频Uri添加到通常添加图像Uri的位置。这出乎意料地起作用了。

private void shareVideoViaTwitter(File file) {
    try {
        Uri uri = FileProvider.getUriForFile(context, "com.civ.petcam.fileprovider", file);

        context.startActivity(new TweetComposer.Builder(context)
                .text("This video is made with PetCamera")
                .url(new URL("https://play.google.com/store/apps/details?id=com.civ.petcam"))
                .image(uri).createIntent().setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));

        onVideoShareCompleteListener.onVideoShareComplete("twitter");
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接