2
有什麼方法可以通過Twitter4j調用Twitter API * update_with_media * POST方法上傳照片?我的意思是,沒有使用TwitPic或YFrog這樣的中間服務?從android與Twitter4j上傳圖片到Twitter
如果這是不可能的,從android原生應用程序發佈圖片推文的最佳方式是什麼?有誰能告訴我有關android應用程序的一個工作示例嗎?
謝謝!
有什麼方法可以通過Twitter4j調用Twitter API * update_with_media * POST方法上傳照片?我的意思是,沒有使用TwitPic或YFrog這樣的中間服務?從android與Twitter4j上傳圖片到Twitter
如果這是不可能的,從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();
}
你得到了答案嗎? –