2015-01-06 38 views
0

我已经在我的项目中集成了yammer feed,现在我需要计算在特定页面(URL)上发表的评论。如何获得评论(消息)在特定的yammer饲料或特定URL上。

yam.connect.embedFeed({ 
container: '#yammer-feed' 
,network: '' 
,feedType: 'open-graph' 
,feedId: '' 
,config: { 
use_sso: false 
, header: true 
, footer: true 
, showOpenGraphPreview: false 
, defaultToCanonical: false 
, hideNetworkName: false, 
hideAttachmentContainer: true 
}, 
objectProperties:{ 
url: "*someurl*", 
type: page 
} 
}); 

我需要知道如何获得上述objectProperties中提到的这个特定URL的所有评论(消息)的计数。 有没有任何yammer API来计数,任何人都可以帮忙吗?

+0

是你能解决这个问题? –

回答

1

有一个API调用来获取打开的图形对象的消息。我用它来获取所有的消息,并通过它们进行计数。首先需要获取页面的Open Graph ID,然后将该ID传递给消息API。

//see if we have an OG object for the current page. 
 
yam.platform.request(
 
    { url: "https://www.yammer.com/api/v1/open_graph_objects?url="+pageURL 
 
    , method: "GET" 
 
    , data: { "body": "This Post was Made Using the Yammer API. Welcome to the Yammer API World." } 
 
    , success: function (msg) { 
 
     //OG object exists. 
 
     ogID = msg.id; 
 
     
 
    } 
 
    , error: function (msg) { 
 
     //OG object doesn't exist, we need to creat it. 
 
    } 
 
});

然后在打开的图形对象ID传递到消息API

//gets the comments count for the OpenGraph object 
 
\t var commentCnt = 0; 
 
\t yam.platform.request(
 
\t \t { url: "https://www.yammer.com/api/v1/messages/open_graph_objects/"+ogID+".json" 
 
\t \t , method: "GET" 
 
\t \t , data: {"body": "This Post was Made Using the Yammer API. Welcome to the Yammer API World."} 
 
\t \t , success: function (msg) { 
 
\t \t \t \t \t if (msg) { 
 
\t \t \t \t   jQuery.each(msg.messages, function (index, element) { 
 
\t \t \t \t \t \t \t commentCnt++; 
 
\t \t \t \t   }); 
 
\t \t \t \t  } 
 
\t \t \t \t \t //adds the count to the webpage. 
 
    \t \t \t \t  jQuery("div#commentCnt").text(commentCnt); 
 
\t \t \t \t } 
 
\t \t , error: function (msg) { 
 
\t \t \t \t \t \t //console.log("message lookup failed"); 
 
\t \t \t } 
 
\t });

+0

我试过使用你的代码,但它只返回最近的20条消息,不超过那个http://stackoverflow.com/questions/25003722/yammer-rest-api-message-comments-and-message-history –

+0

,我需要得到总消息数量为该特定的URL。 –

+0

看起来像Yammer将它限制为20条消息。查看这篇文章,了解如何通过使用Older_than和页面获得20多个想法。 http://stackoverflow.com/questions/20538349/yammer-json-feed-returning-only-20-messages – Jasbury