简体   繁体   中英

How to post picture to Twitter using twitter4j library in Android

I want to post image to twitter on my app. I use "twitter4j" library to post only text. But i cannot find how to post image with text. Thanks for help.

  1. To post a image you have to use media extension of Twitter4j and register your app with either TwitPic or YFrog .
  2. Get KEY and TOKEN from those services and then

     /* * Upload File to twitPic and get url . Then append this url to your twitter message. */ public static String upload_twic_pic(File file) throws TwitterException { String url = null; if (file != null) { Configuration conf = new ConfigurationBuilder().setMediaProviderAPIKey(TWITPIC_KEY).build(); ImageUpload upload = new ImageUploadFactory(conf).getInstance(MediaProvider.PLIXI); //Use ImageUploadFactory url = upload.upload(file); } return url; 

是一个文件解决方案的链接,该解决方案确切说明了如何将图片/文本推文集成到android应用中。

You can use socialauth android library

Find SocialAuth Android Here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM