1

我正在尝试使用 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);

但是,我在时间轴上只看到文本:我的消息。

用户具有以下权限:

'manage_pages, publish_stream, create_event, photo_upload'

可能是什么问题呢?

4

1 回答 1

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"));
于 2012-12-09T08:22:22.420 回答