我已经从Git下载了 Facebook Android SDK,并按照developers.facebook中的步骤进行操作,获得了应用程序 ID 并运行了一些示例代码。我可以在墙上发布状态。现在我想在墙上上传一张带有描述或标题的照片,但我不能。我浏览并发现以下代码作为照片上传的答案。
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","aid":"100003180585600_43760","owner":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","link":"http://www.facebook.com/photo.php?fbid=1989304802293770&set56002293673&set56148.jpg 100003180585600&type=1","caption":"So Cuuteee!!","created":1333718624,"object_id":198930480222970}
照片以小尺寸图片的形式上传到某个地方(它提供了一些 URL)。但不在 Facebook 墙上或相册上。通过查看 Stack Overflow 问题Android - How to upload photo from 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"}}
怎么上传到墙上?