根据我进行的几次搜索,这是我为了发送我刚刚保存在 SD 卡上的图像而写的
public void postToWall() throws FileNotFoundException, MalformedURLException, IOException {
loginToFacebook();
if (facebook.isSessionValid()) {
// Ok le login est bien enregistre
Bundle bundle = new Bundle();
bundle.putString("message","test");
File file = (File) this.getIntent().getExtras().get("PICTURE_TAKEN");
FileInputStream fis = new FileInputStream(file);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int data2 = 0;
while ((data2 = fis.read()) != -1)
baos.write(data2);
fis.close();
byte[] bytes = baos.toByteArray();
baos.close();
bundle.putByteArray("Picture", bytes);
mAsyncRunner.request("me/feed", bundle, "POST", new FacebookPostListener(), null);
}
}
我成功发布了短信“消息”,但没有发布图片!(额外的“PICTURE_TAKEN”是与拍摄照片相关的文件)