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

如果不可能,从Android本机应用程序发布带有图片的推文的最佳方法是什么?有人可以告诉我有关Android应用程序的有效示例吗?

谢谢!!

最佳答案

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();
            }

08-27 00:49