我正在尝试使用restfb将照片发布到用户的页面时间轴。
我的代码是这样的:
// Create parameters for the call
Collection<Parameter> params = new ArrayList<Parameter>();
params.add(Parameter.with("message", "My Message"));
Parameter postParamsArray[] = params.toArray(new Parameter[params.size()]);
java.net.URL url = new java.net.URL("http://i.istockimg.com/file_thumbview_approve/4739627/2/stock-illustration-4739627-dreidel-game.jpg");
FacebookType publishMessageResponse = facebookClient.publish(facebookWallURL, FacebookType.class,BinaryAttachment.with("dreidel.jpg", url.openStream()), postParamsArray);
但是,我在时间轴上只看到了文字:My Message。
用户具有以下权限:
'manage_pages, publish_stream, create_event, photo_upload'
可能是什么问题?
答案 0 :(得分:3)
facebookWallURL - 看起来你正在张贴到墙上。请尝试发布到相册:
facebookURL = facebookPageId + "/photos";
publishMessageResponse = facebookClient.publish(facebookURL, FacebookType.class, ba, postParamsArray);
如本例所示:
(注意“我/视频”)
http://restfb.com/
Publishing a Photo (see Graph API documentation)
// Publishing an image to a photo album is easy
// Just specify the image you'd like to upload and RestFB will handle it from there.
FacebookType publishPhotoResponse = facebookClient.publish("me/photos", FacebookType.class,
BinaryAttachment.with("cat.png", getClass().getResourceAsStream("/cat.png")),
Parameter.with("message", "Test cat"));
out.println("Published photo ID: " + publishPhotoResponse.getId());
// Publishing a video works the same way as uploading a photo.
facebookClient.publish("me/videos", FacebookType.class,
BinaryAttachment.with("cat.mov", getClass().getResourceAsStream("/cat.mov")),
Parameter.with("message", "Test cat"));