我正在嘗試從用戶牆上的設備發佈圖像。我發現:http://codenameone.blogspot.com/2011/09/lwuit-and-facebook-api-by-chen-fishbein_18.html,但它不支持圖像後,所以我寫了這樣一個簡單的方法:j2me facebook圖api - 在用戶牆上發佈圖像
public void postOnWallWithPhoto(String userId, String message, byte[] img) throws IOException {
checkAuthentication();
FacebookRESTService con = new FacebookRESTService(token, userId, FEED, true);
con.setContentType("image/jpeg");
con.addArgument("message", message);
con.addArgument("type", "photo");
con.addArgument("picture", img);
if (slider != null) {
SliderBridge.bindProgress(con, slider);
}
for (int i = 0; i < responseCodeListeners.size(); i++) {
con.addResponseCodeListener((ActionListener) elementAt(i));
}
current = con;
NetworkManager.getInstance().addToQueueAndWait(con);
}
這種方法被稱爲這種方式:
FileConnection fc = (FileConnection) Connector.open(path);
InputStream is = fc.openInputStream();
byte[] b = new byte[(int) fc.fileSize()];
is.read(b);
FaceBookAccess.getInstance().postOnWallWithPhoto(me.getId(), "test2", b);
後,我發送請求,在牆上只顯示文本(在本例中爲test2)。在哪裏應該是一個圖像,有一個消息:「無效無效」。
有沒有人有想法,我做錯了什麼?或者有人可以與我分享一段代碼,以幫助我在Facebook牆上發佈圖片?
還有一個在http://kenai.com/projects/facebookapime/pages/Home Java ME的這個實等API你能試試嗎? – 2012-07-31 12:56:22
是的,我也試過這個。它不支持在牆上張貼圖像。 – Marcin 2012-07-31 13:59:42