Yammer API - 在 Yammer 上创建帖子

标签 yammer

我正在尝试使用 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 是什么?我如何告诉它我想将帖子发布到哪个组?

非常感谢任何建议

亚默

最佳答案

...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

关于Yammer API - 在 Yammer 上创建帖子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26277837/

相关文章:

yammer - 在不显示弹出窗口的情况下强制登录 Yammer

rest - Yammer REST API - 记录的参数不起作用

api - Yammer api : Get messages by group

oauth-2.0 - 使用 WebBrowser 控件嵌入 Yammer

javascript - Yammer 嵌入自定义字体大小

javascript - Yammer 附件

java - 如何在 Android 上使用 Jackson 将 JSON 数组解析为不同的对象?

ios - #yammer iOS SDK出现问题