2014-07-09 73 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。

我糾正了這一點,並開始完美的工作。

我不是說這可能是你的情況,但希望它有幫助。