Best way to upload video on twitter

2019-04-10 17:26发布

I have to upload video to twitter (post a tweet text with video) from my java application. I use twitter4j to upload images and it works perfectly. I'm confused about the best way to upload video. I have found in this link https://github.com/mrisney/twitter-java-ads-sdk/blob/master/src/examples/VideoUploadExample.java the code that implements the twurl command but I want to know if it's possible to upload video with twitter4j like I have done for the image? Or have I to use the twurl way to do it? And is there any possibility to post video directely on twitter?

This is what I do for the image upload

     `  Twitter twitter = new TwitterFactory().getInstance();
        twitter.setOAuthConsumer(consumerKey, consumerSecret);
        AccessToken accessToken = new AccessToken(accessTokenStr,
                accessTokenSecret);
        twitter.setOAuthAccessToken(accessToken);
        StatusUpdate statusUpdate = new StatusUpdate(text);
        statusUpdate.setMedia("New pic", new URL(photo).openStream());
        twitter.updateStatus(statusUpdate.inReplyToStatusId(tweetId));` 

Thanks

0条回答
登录 后发表回答