javascript - Yammer 开放图 API 错误 400

标签 javascript api yammer

我尝试使用 Open Graph 写入 Yammer 事件源,但收到 400 错误请求错误。我想知道网址或数据是否错误。

function postToActivity() {
    yam.getLoginStatus( function(response) {
        if (response.authResponse) {
            yam.request(
              { url: "https://api.yammer.com/api/v1/activity.json" //note:  the endpoint is api.yammer...
              , method: "POST"
              , data: {
                  "activity" : {
                    "actor" : {
                        "name" : "Ken Domen",
                        "email" : "ken.domen@nike.com",
                        "action" : "like",
                        "object" : {
                            "url" : "http://www.google.com",
                            "title" : "Test"
                         }
                     }
                  }
                }
              , success: function (msg) {
                    alert("Post was Successful!: " + msg.messages[0].id); //id of new message
              }
              , error: function (msg) { alert("Post was Unsuccessful..." + msg); }
              }
            );
        } else {
            yam.login( function (response) {
               //nothing
            });
        }
    });
}

最佳答案

嗯,这对我有用:

创建开放图谱页面:

yam.platform.request({
        url: "https://api.yammer.com/api/v1/activity.json",
        method: "POST",
        data: {
            "activity": {
                "actor": { "name": "my name", "email": "my email" },
                "action": "create",
                "object": { "url": "http://google.is", "title": "the page title"},
                "type": "url"
            }
        },
        success: function (res) { 
            alert("The request was successful.");
            console.dir(res);
        },
        error: function (res) {
            alert("There was an error with the request.");
            console.log(res)
        }
    })

将消息发布到打开的图表页面:

yam.platform.request({
        url: "https://api.yammer.com/api/v1/messages.json",
        method: "POST",
        data: {
          "body" : "Message body",
          "group_id": "grup id, i.e. 12345678",
          "og_url": "http://google.is"

        },
        success: function (res) { //print message response information to the console
            alert("The request was successful.");
            console.dir(res);
        },
        error: function (res) {
            alert("There was an error with the request.");
            console.log(res)
        }
    })

关于javascript - Yammer 开放图 API 错误 400,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24657648/

相关文章:

javascript - 如何使用 jquery/js 使内容在悬停时显示在另一个下方(如 <li> 列表)

javascript - Macro Express Pro JavaScript 中的 VBScript echo 等效项

api - 使用 playerVars : { 'rel' : 0 } for removing but it not working 的 Youtube 视频 API

javascript - 谷歌地图 setVisible 不是函数

api - Yammer api : Get messages by group

dropwizard - 如何将 riemann 集成到 dropwizard 中以捕获指标?

javascript - 无法动态地将值设置到标签中

javascript - 如果脚本已更新,如何刷新页面的缓存?

internet-explorer - 如何删除 Vista/Win7 上的 IE 地址栏历史记录?

java - 如何使用 REST API 发布 Yammer 民意调查?