我已經從Git下載了Facebook Android SDK,並按照developers.facebook中的步驟操作,並獲得了應用程序ID並運行了一些示例代碼。我可以在牆上張貼狀態。現在我正試圖在牆上貼一張描述或標題,但我不能。我瀏覽過,大多數情況下我找到了下面的代碼作爲照片上傳的答案。從Android上傳照片到Facebook牆/相冊
public void postImageonWall() {
byte[] data = null;
Bitmap bi = BitmapFactory.decodeFile("/sdcard/cutedog.jpg");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bi.compress(Bitmap.CompressFormat.JPEG, 100, baos);
data = baos.toByteArray();
Bundle params = new Bundle();
params.putString(Facebook.TOKEN, mFacebook.getAccessToken());
params.putString("method", "photos.upload");
params.putByteArray("picture", data);
params.putString("caption", "So Cuuteee!!");
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
mAsyncRunner.request(null, params, "POST", new SampleUploadListener(), null);
}
對於這一點,我得到的迴應是 { 「PID」: 「100003180585600_320223」, 「援助」: 「100003180585600_43760」, 「主人」:100003180585600, 「SRC」:「HTTP:// photos- g.ak.fbcdn.net/hphotos-ak-prn1/533575_198930480222970_100003180585600_320223_995139351_s.jpg","src_big":"http://a7.sphotos.ak.fbcdn.net/hphotos-ak-prn1/s720x720/533575_198930480222970_100003180585600_320223_995139351_n.jpg」 「src_small」: 「http://photos-g.ak.fbcdn.net/hphotos-ak-prn1/533575_198930480222970_100003180585600_320223_995139351_t.jpg」, 「鏈接」:「http://www.facebook.com/photo.php? fbid = 198930480222970 & set = a.198930373556314.43760.100003180585600 & type = 1「,」caption「:」So Cuuteee !!「,」created「:1333718624,」object_id「:198930480222970}
該照片上傳到某處(它給出了一些URL)作爲一個小尺寸的圖片。但不是在Facebook的牆上或專輯。通過觀察堆棧溢出問題Android - How to upload photo from the SD card to the Facebook wall,我試圖
mAsyncRunner.request("me/photos", params, "POST", new SampleUploadListener(), null);
和
mAsyncRunner.request("me/feed", params, "POST", new SampleUploadListener(), null);
在這兩方面,我得到了下面的響應
{"error":{"message":"Unsupported method, photos.upload","type":"Exception"}}
如何在牆壁上上傳?
謝謝Rstar..I可以上傳使用該示例,但是當我嘗試作爲獨立項目(我自己的)我不能添加com_facebook_android作爲庫項目,當我添加它沒有采取..只是顯示交叉mark.any想法請.. – Karthi 2012-04-09 05:07:22