有什么方法可以调用 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();
}