2014-07-09 50 views
1

我试图用Open Graph写入Yammer Activity Feed,但是我得到了400错误的请求错误。我想知道如果网址或数据是错误的。Yammer打开图形API错误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" : "[email protected]", 
         "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 
      }); 
     } 
    }); 
} 

回答

1

好了,这对我的作品:

创建的Open Graph页面:

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) 
     } 
    }) 
+0

谢谢!这工作! – kendomen

0

我有山姆e 400错误。在我的情况下,解决方案非常简单。我正在使用group_id组的名称,而不是group_id。 。

你可以将浏览器指向你所感兴趣的组GROUP_ID在URL参数,你必须:?类型= in_group & feedId = 3028738的feedId是GROUP_ID。

我纠正了这一点,并开始完美的工作。

我不是说这可能是你的情况,但希望它有帮助。