我想在我的应用程序上将图像发布到 Twitter。我使用“twitter4j”库仅发布文本。但我找不到如何用文本发布图像。感谢您的帮助。
最佳答案
- 要发布图像,您必须使用 Twitter4j 的媒体扩展并使用 TwitPic 或 YFrog 注册您的应用。
从这些服务获取 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;
关于java - 如何在Android中使用twitter4j库将图片发布到Twitter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9693586/