我正在尝试从用户墙上的设备发布图像。我发现: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