0

我试图弄清楚应如何构造有效负载以将 Open Graph 对象提交给 yammer。我可以发布一条标准消息,但我想发布一条 opengraph 消息。

{
"activity":{
    "actor":{"name":"Sidd Singh",
    "email":"sidd@xyz.com"},
    "action":"create",
    "object": {
        "url":"https://www.sched.do",
        "title":"Lunch Meeting"
    },
    "message":"Hey, let’s get sushi!",
    "users":[
        {"name":"Adarsh Pandit",
        "email":"adarsh@xyz.com"}
    ]
  }
}

这是从他们的 API 文档中截取的一些代码,但没有告诉我应该如何在 javascript 中使用它。有人可以帮助我吗?以下是我发布标准消息的现有代码...

yam.request({
        url: "https://www.yammer.com/api/v1/messages.json?network_id=networkname",     //this is one of many REST endpoints that are available
        method: "POST",
        beforeSend: function (req) { //send the access_token in the HTTP header
            req.headers.Authorization = "Bearer " + access_token;
        },
        data: {         
          "network": "networkname",
          "body": "Test Post",
          "group_id": "3719771"
        },
        success: function (data) { //print message response information to the console
            toastr.success('An Item was successfully posted to Yammer', "Yammer Network");  
        },
        error: function (user) {
            toastr.error('There was an error eith the request', "Yammer Network");  
        }
      });   
4

1 回答 1

0

这篇文章回答了您的问题:Yammer Open Graph API Error 400

只需将 中的键值对替换data{}为活动 json 字符串即可。还记得将 RESTful api 端点更改为https://api.yammer.com/api/v1/activity.json

于 2014-07-25T00:31:12.147 回答