2011-12-13 55 views
4

我一直在尋找到春天社會Facebook的發佈(OBJECTID,則connectionName,數據)API,但我不知道這個API(可悲的用法,由於缺乏的javadoc的!)。有人能指點我一個全面的API使用範例嗎?春天社會的Facebook - 發佈/後API細節

我所希望做的是發佈在用戶的牆上的故事,類似下面的快照:

enter image description here

應如何發佈()API被用來做?任何幫助,高度讚賞!

此外,我需要我的文章有額外的行動(除了贊,評論)。

+1

難道只有通過彈簧社會希望這樣?我通過Spring Rest(使用RestTemplete或Httpclient)解決了問題。 –

回答

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); 
+0

我做了同樣的,所有工作,但圖像沒有顯示,img src是正確的,包括我的圖像url,但沒有加載,我需要別的東西嗎? –

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); 
} 
+0

我不認爲Spring的javadoc鏈接在這種情況下有很多用處。我相信需要更多關於API參數內容的文檔。另外,你給出的參考文獻也是微不足道的。例如,我正在尋找的是如何設置* data *參數(即要添加到地圖的值),以便對帖子進行自定義操作。 – Saket

+0

我已經更新了答案。 –

+1

我使用像Somnath's這樣的代碼,再加上我在地圖中設置了這些額外的鍵/值對: 'map.set(「message」,message); //「很難想象......」部分適合你'和'map.set(「picture」,linkPictureURL); //圖標網址' 另外,如果不清楚,'FEED'常量的值應該是'feed''。 – sdouglass

0

上面一樣的答案,但我使用後我解。看到這一點:

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); 

+0

我更新我的答案,您的Facebook應用需要禁用流發佈URL安全。 您的應用/設置/遷移/禁用流發佈URL安全 –