【问题标题】:Uploading pictures to Twitter from android with Twitter4j使用 Twitter4j 从 android 将图片上传到 Twitter
【发布时间】:2012-06-11 11:13:21
【问题描述】:

有没有什么方法可以调用 Twitter API *update_with_media* POST 方法来使用 Twitter4j 上传照片?我的意思是,不使用 TwitPic 或 YFrog 等中间服务?

如果不可能,从 android 原生应用中发布带有图片的推文的最佳方式是什么?谁能告诉我一个适用于 Android 应用程序的示例?

谢谢!!

【问题讨论】:

    标签: android twitter media twitter4j tweets


    【解决方案1】:
    if (requestCode == CAMERA_REQUEST) {
                mImageUri = data.getData(); 
                mPath = getRealPathFromURI(mImageUri); //from Gallery 
    
                if (mPath == null)
                    mPath = mImageUri.getPath(); //from File Manager
    
                if (mPath != null) 
                    bitmap  = BitmapFactory.decodeFile(mPath);
            } else {
                mPath   = mImageUri.getPath();
                bitmap  = BitmapFactory.decodeFile(mPath);
            }
    Authorization auth=twitter.getAuthorization();
                ImageUpload uploadPhoto=ImageUpload.getTwitpicUploader(TwitPic_api_Key, (OAuthAuthorization) auth);
                Log.d(TAG, "Start sending image...");
    
                try {
                    url = uploadPhoto.upload(new File(mPath));
                    result = 1;
                    Log.d(TAG, "Image uploaded, Twitpic url is " + url);            
                } catch (Exception e) {        
                    Log.e(TAG, "Failed to send image");
    
                    e.printStackTrace();
                }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-09-20
      • 1970-01-01
      • 2015-03-28
      • 1970-01-01
      • 2011-03-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多