如何使用Android中的twitter4j库将图片发布到Twitter

我想在我的应用上将图片发布到twitter。 我使用“twitter4j”库只发布文本。 但我找不到如何用文字发布图像。 感谢帮助。

  1. 要发布图像,您必须使用Twitter4j的媒体扩展,并使用TwitPic或YFrog注册您的应用。
  2. 从这些服务中获取KEY和TOKEN然后

    /* * 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应用程序中。

你可以使用socialauth android库

在这里找到SocialAuth Android