0

我能够将消息发布到 yammer,但消息被发布到默认网络,我需要在不同的网络中发布。

这是我当前的测试代码:

<html>
<head>
    <title>A Yammer App</title>
    <script src="https://assets.yammer.com/platform/yam.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script>
      yam.config({appId: "######"});
    </script>
</head>
<body>
    <button onclick='post()'>Yammer Update!</button>
    <script>
    function post() {
        yam.getLoginStatus( function(response) {

            if (response.authResponse) {


                postdata();

            } else {
                yam.login( postdata);

            }
        });
    }
function postdata()
{
yam.request(
                  { url: "https://www.yammer.com/api/v1/messages.json"
                  , method: "POST"
                  , data: { "body" : "Message Throug app","group_id":"3156478"}
                  , success: function (msg) { alert("Post was Successful!: " + msg); }
                  , error: function (msg) { alert("Post was Unsuccessful..." + msg); }
                  }
    );
}
    </script>
</body>
</html>
4

1 回答 1

0

在发送之前在您的 yam.request 中添加以下函数。

   beforeSend: function (req) {
              //send the access_token in the HTTP header    
               req.headers.Authorization = "Bearer ####@#@#@SSA";
        }

持有者将获得您所针对的网络的授权令牌。

于 2013-11-18T11:32:17.113 回答