2014-09-24 16 views
1

我想使用php和javascript創建yammer狀態。這是但─Yammer REST API用於創建主題狀態並獲取主題Id

<script type="text/javascript" data-app-id="client-id" src="https://c64.assets-yammer.com/assets/platform_js_sdk.js"></script> 
    <span id="yammer-login"></span> 
    <script> 
     $(function(){ 

      yam.connect.loginButton('#yammer-login', function (resp) { 
       if (resp.authResponse) { 
        yam.platform.request({ 
         url: "messages.json", 
         method: "POST", 
         data: { 
          "body" : "Message body", 
          "group_id": "4728511", //group id 
          "topic1": "TestTopic1", 
          "og_url": "http://google.com" 
         }, 
         success: function (res) { //print message response information to the console 
          alert("The request was successful."); 
          console.dir(res); 
          yam.platform.request({ 
           url: "https://www.yammer.com/api/v1/search.json", 
           method: "GET", 
           data: { 
            "search" : "TestTopic1" 
           }, 
           success: function (data) { //print message response information to the console 
            alert("The request was successful."); 
            console.dir(data); 
           }, 
           error: function (data) { 
            alert("There was an error with the request."); 
            console.log(data) 
           } 
          }); 
         }, 
         error: function (res) { 
          alert("There was an error with the request."); 
          console.dir(res); 
         } 
        }); 
       } 
      }); 

的狀態上哭訴,但其示值誤差更新了我的示例代碼中,我還沒有拿到主題ID。 那麼我該如何糾正它..?

在此先感謝

+0

如果你明確你接受它會幫助大家回答錯誤消息的問題更容易。 – 2014-09-24 16:10:57

回答

0

它看起來就像你到search.json第二個電話是罪魁禍首。當使用JS SDK時,您應該直接調用REST資源,而不是放入URL(如:www.yammer.com或api.yammer.com)。

你與你的第一次調用messages.json成功地做到了這一點,但應該更新你的第二個電話本:

yam.platform.request({ 
    url: "search.json", 
    method: "GET", 
    data: { 
    "search" : "TestTopic1" 
    }, 
    success: function (data) { //print message response information to the console 
    alert("The request was successful."); 
    console.dir(data); 
    }, 
    error: function (data) { 
    alert("There was an error with the request."); 
    console.log(data) 
    } 
}); 
+0

感謝你的回覆,實際上當我第一次打電話時,狀態正在創建它的不成功功能,而不是它進入錯誤功能和打印時的狀態 'console.dir(res);' 其顯示 [dropbox_error_image](https://www.dropbox.com/s/1wrg9144dr42cbc/yammer.JPG?dl=0) – 2014-09-25 06:24:52