Spring社交Facebook - 发布/发布API详细信息

时间:2011-12-13 09:49:46

标签: java facebook spring facebook-graph-api spring-social

我一直在研究Spring Social Facebook的发布(objectId,connectionName,data) API,但我不确定这个API的用法(遗憾的是,由于缺少javadocs !)。有人可以指点我对API的全面样例使用吗?

我要做的是在用户的墙上发布一个故事,类似于下面的快照:

enter image description here

如何使用 publish()API 来做同样的事情?任何帮助都非常感谢!

此外,我需要我的帖子有其他操作(除了喜欢,评论)。

3 个答案:

答案 0 :(得分:6)

The link由您提供了很多方法文档。

查找流程为publish(objectId, connectionName, data) here

的示例

另请参阅github-SpringSource的许多示例,了解其他操作,包括publish(objectId, connectionName, data)

更新

您可以从此方法获得一些帮助:

public void postToWall(String message, FacebookLink link) {
    MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
    map.set("link", link.getLink());
    map.set("name", link.getName());
    map.set("caption", link.getCaption());
    map.set("description", link.getDescription());
    map.set("message", message);
    publish(CURRENT_USER, FEED, map);
}

答案 1 :(得分:1)

这是我最终可以弄清楚的:

MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
map.set("link", linkUrlString);
map.set("name", "Link Heading");
map.set("caption", "Link Caption");
map.set("description", "Loooooo....ng description here");
map.set("message", "hello world");

// THE BELOW LINES ARE THE CRITICAL PART I WAS LOOKING AT!
map.set("picture", "http://www.imageRepo.com/resources/test.png"); // the image on the left
map.set("actions", "{'name':'myAction', 'link':'http://www.bla.com/action'}"); // custom actions as JSON string

publish(userIdToPostTo, "feed", map);

答案 2 :(得分:0)

像上面的回答一样但我使用post来解决问题。见:

MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
        map1.set("link", "https://www.facebook.com/profile.php?id=100006216492034");
        map1.set("name", "Project Test Post to Group");
        map1.set("caption", "Please ignore this Post");
        map1.set("description", "YOLO here is my discription, Please ignore this post");
facebook.post("userId or GroupID", "feed", map);

相关问题