我正在使用restfb在Facebook页面上创建带有child_attachments(轮播)的帖子。
这是创建DefaultFacebookClient并尝试发布帖子的代码:
public String post(List<News> newsList)
{
try
{
FacebookClient facebookClient = new DefaultFacebookClient(ACCESS_TOKEN, APP_SECRET, Version.LATEST);
List<Post> attachments = new ArrayList<>();
for(int i = 0; i < 4; i++)
{
PostCallToActionValue postCallToActionValue = new PostCallToActionValue();
postCallToActionValue.setLink(newsList.get(i).GetNewsUrl());
postCallToActionValue.setLinkTitle(newsList.get(i).GetTitle());
PostCallToAction postToAction = new PostCallToAction();
postToAction.setType("NO_BUTTON");
postToAction.setValue(postCallToActionValue);
Post post = new Post();
post.setPicture(newsList.get(i).GetImageUrl());
post.setName(newsList.get(i).GetTitle());
post.setLink(newsList.get(i).GetNewsUrl());
post.setCaption("Asewome description here ...");
post.setDescription(newsList.get(i).GetDescription());
post.setCallToAction(postToAction);
attachments.add(post);
}
FacebookType publishMessageResponse = facebookClient.publish(FACEBOOK_PAGE + "/feed",
FacebookType.class,
com.restfb.Parameter.with("message", "Awesome message here ..."),
com.restfb.Parameter.with("multi_share_end_card", false),
com.restfb.Parameter.with("child_attachments", attachments)
);
String facebookUrl = "http://www.facebook.com/permalink.php?story_fbid=" + publishMessageResponse.getId() + "&id=" + FACEBOOK_PAGE;
return facebookUrl;
}
catch (RuntimeException e)
{
throw e;
}
}
我从Facebook Api收到此错误:
"Received Facebook error response of type OAuthException: (#100) Invalid keys \"likes\" were found in param \"child_attachments[0]\". (code 100, subcode null) 'null - null'"
在对Open Graph进行了大量研究之后,我不知道“喜欢”键是什么。
有什么建议吗?
谢谢!