2012-03-13 58 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應用程序一個文件解決方案的鏈接。