如何使用链接用户在Yammer Group中发布消息?

时间:2017-08-22 06:23:57

标签: javascript json rest api yammer

Yammer REST api json。我的代码在group succesfull中发送消息。但我需要发送带有“cc”的msg,链接一些用户,如下所示:

this


       function yamPostRequest(val) {
           var msg_value = document.getElementById('msg_body').value;
           var groupID = document.getElementById('group_id').value;
           if (msg_value == "") {
               alert("Message body cannot be empty!");
               return false;
           }
           if (groupID == "") {
               var conf = confirm("Group ID is empty, message will be posted to All Company");
               if (conf == false) {
                   return false;
               }
           }
           yam.platform.request({
               url: "https://api.yammer.com/api/v1/messages.json",
               method: "POST",
               data: {
                   "body": msg_value,
                   //"title" : msg_title,
                   "group_id": groupID,
               },
               success: function(msg) {
                   alert("Post was Successful!");
               },
               error: function(msg) {
                   alert("Post was Unsuccessful");
               }
           })
       }

1 个答案:

答案 0 :(得分:0)

我找到了。

function PostYammerWithNotification(group_id, message, userCC) {

    var yammerData;
    yammerData = {
        group_id: group_id,
        body: message
    };
    yammerData.cc = "[[user:" + userCC + "]]";

    yam.platform.request({
        url: "https://api.yammer.com/api/v1/messages.json",
        method: "POST",
        data: yammerData,
        success: function(msg) {
            alert("Post was Successful!");
        },
        error: function(msg) {
            alert("Post was Unsuccessful");
        }
    });
}

您需要使用用户ID:

PostYammerWithNotification(/*Group ID*/,"test msg",/*User ID*/)

找到它here