java - 如何在Android中使用twitter4j库将图片发布到Twitter

标签 java android twitter twitter4j

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

关于java - 如何在Android中使用twitter4j库将图片发布到Twitter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9693586/

相关文章:

Java Swingworker线程

java - Android UI 线程停止从其他线程更新

javascript - 如何在twitter api中的关注按钮回调函数中检索用户详细信息?

php - 如何在 PHP 中使用 Twitter Streaming API?

java - com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException : Cannot delete or update a parent row: a foreign key constraint fails

java - 编辑时动态增加JTable行高,编辑完成时动态减少JTable行高

java - java中的属性文件如何工作?

Android 显示日期选择器(结束日期)大于开始日期?

java - 由于 "No package identifier when getting value of resource number..."而崩溃

python - GetSearch还是SreamListener? Python