我尝试使用Yammer API在Yammer上创建帖子, 我有以下代码:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/TR/html5/">
<head>
<meta charset="utf-8" />
<title>YammerNotification - Version 1</title>
<script src="https://assets.yammer.com/platform/yam.js"></script>
<script>
yam.config({ appId: "APP-ID" });
</script>
</head>
<body>
<button onclick='post()'>Post on Yammer!</button>
<script>
function post() {
yam.getLoginStatus(function (response) {
if (response.authResponse) {
yam.request(
{
url: "https://www.yammer.com/api/v1/messages.json"
, method: "POST"
, data: { "body": "This Post was Made Using the Yammer API. Welcome to the Yammer API World." }
, success: function (msg) { alert("{Post was Successful!}: " + msg); }
, error: function (msg) { alert("Post was Unsuccessful..." + msg); }
}
)
} else {
yam.login(function (response) {
if (!response.authResponse) {
yam.request(
{
url: "https://www.yammer.com/api/v1/messages.json"
, method: "POST"
, data: { "body": "This Post was Made Using the Yammer API. Welcome to the Yammer API World." }
, success: function (msg) { alert("{Post was Successful!}: " + msg); }
, error: function (msg) { alert("Post was Unsuccessful..." + msg); }
}
);
}
});
}
});
}
</script>
</body>
</html>
虽然我的APP ID是什么?我怎么告诉它我想把帖子放到哪个组?
非常感谢任何建议
答案 0 :(得分:4)
...what would my APP ID be?
您需要注册此处记录的应用 - https://developer.yammer.com/introduction/#gs-registerapp,您的APP ID是客户ID的值
And how do I tell it what group I want to put a post to?
在json数据输入中指定groupID:
data: {
"body": "This Post was Made Using the Yammer API. Welcome to the Yammer API World."
,"group_id" : groupID
}
请在此处查看完整示例代码 - http://blogs.technet.com/b/israelo/archive/2014/10/21/yammer-js-sdk-for-dummies.aspx
答案 1 :(得分:0)
在此处查找示例:http://www.sharepointyammertech.com/2014/12/yammer-sharepoint-2013-how-to-post.html。
Data-App-id是一种用于识别Yammer REST请求来自有效应用程序的id。在创建新的Data-App-Id时,您需要在“JavaScript Origins”中提及您的网站网址 以下是您可以在其中创建新的Data-App-Id的网址:https://www.yammer.com/client_applications。