2012-03-13 56 views

回答

5
  1. 要发布图片,您必须使用Twitter4j的媒体扩展程序,并使用TwitPic或YFrog注册您的应用程序。从这些服务
  2. 获取密钥和令牌,然后

    /* 
    * 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; 
    
+0

它不工作。应用程序崩溃,因为 ImageUpload upload = new ImageUploaderFactory(conf).getInstance(MediaProvider.PLIXI); – 2012-03-15 10:47:41

+0

您是否添加了Twitter4j的媒体扩展jar?也发布跟踪。 – kodeshpa 2012-03-15 17:21:06

+0

@ user408904 ImageUpload upload = new ImageUploadFactory(conf).getInstance(MediaProvider.PLIXI);我得到一个oauth授权是这一行中必需的错误。你能帮我解决吗? – 2012-08-29 13:21:35

1

Here是解释究竟是如何图片/文本鸣叫集成到Android应用程序一个文件解决方案的链接。