繁体   English   中英

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

[英]How to post picture to Twitter using twitter4j library in Android

我想在我的应用程序上将图像发布到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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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