2014-09-24 3 views
1

php 및 javascript를 사용하여 yammer 상태를 만들고 싶습니다. 이것은 내 샘플 코드입니다.주제가있는 상태를 작성하고 주제를 다시 얻으려는 Yammer REST API

<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); 
         } 
        }); 
       } 
      }); 

상태가 yammer에서 업데이트되지만 표시 오류가 발생합니다. 또한 주제 ID를받지 못했습니다. 그래서 어떻게 해결할 수 있습니까 .. ?? search.json에 두 번째 호출이 범인처럼 사전에

덕분에

+0

당신의 더 쉽게 질문. –

답변

0

것 같습니다. JS SDK를 사용할 때 URL에 넣는 대신 직접 REST 리소스를 호출해야합니다 (예 : 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) –