【问题标题】:Yammer REST API - Get all messages older message before newer and therefore cannot return older_thanYammer REST API - 在新消息之前获取所有消息较旧的消息,因此无法返回 old_than
【发布时间】:2019-01-02 10:30:33
【问题描述】:

我们正在尝试从 Yammer 中的特定组中检索所有消息,但在某些情况下检索旧消息时遇到问题。

示例:

在 Yammer 组中的每个帖子都是同步添加且不被评论或喜欢的理想世界中,我们可以使用参数 old_than:id 轻松检索每条消息

但是,如果评论了较旧的消息,则该消息似乎会在新消息之间返回。

这可能会导致边缘情况,即旧消息是消息数组中的最后一项,并且当使用该消息项 id 查询旧消息时,我们只会获取比该消息更旧的消息,并且可能不会在两者之间返回新消息。

我们正在使用此处记录的 REST API /messages/in_group/[:group_id].json:

https://developer.yammer.com/docs/messagesin_groupgroup_id

代码示例:

我们精简了代码示例以说明我们检索所有消息的方法。

yam.platform.request({
url: 'messages/in_group/' + vm.webpartSettings.feedId + '.json?threaded=true' + (oldest ? ('&older_than=' + oldest) : ''),
method: 'GET',
success: function (response) {

    // Parse messages
    var lastId;
    var parsedMessages = response.messages.map(function (m, i) {
        if (i === (response.messages.length - 1)) {
            lastId = m.id;
        }

        return {
            id: m.id,
            author: response.references.filter(function (r) {
                r.type === 'user' && r.id === m.sender_id;
            })[0],
            date: new Date(m.created_at),
            url: m.web_url,
            image: getImageFromAttachments(m.attachments),
            text: m.body.parsed,
            likes: m.liked_by.count,
            likedByCurrentUser: m.liked_by.names.some(function (u) {
                return u.user_id === response.meta.current_user_id;
            })
        };
    }).filter(function (m) {
        return m.image;
    });

    vm.messages = vm.messages.concat(parsedMessages);

    // If there are more messages get them, otherwise render the grid
    if (response.meta.older_available) {
        getAndParseMessages(lastId);
    } else {
        // render method removed       
    }
},
error: function (response) {
    // error method removed
}
});

当使用查询参数 threaded:true 调用 API 时,我们希望检索每个线程的线程启动器(第一条消息),并让它们按创建日期而非“最新活动”排序。

有谁知道这个功能是如何用来查询旧消息的,还是我们遗漏了什么?

更新

我为 Yammer 创建了一个用户语音,以与完整的 Office 365 开发人员平台集成。你可以在这里投票:https://yammer.uservoice.com/forums/399627-yammer/suggestions/36474385-integrate-yammer-in-the-full-office-365-developer

【问题讨论】:

    标签: yammer


    【解决方案1】:

    您应该将Data Export API 用于此类批量数据任务。 REST API 是为用户客户端应用程序设计的,以您所遵循的模式查询数据是其中的约束之一。

    【讨论】:

    • 感谢@BrianLyttle 的回答。我看到有人提到 Yammer API 版本 2 - 是否有计划公开或通过 MS Graph 提供更多 API?如果能够使用 Yammer 做更多事情,那就太好了。
    • 另外,我觉得API对此并不清楚,而文档说它可以查询“指定组中的所有消息”。我们在 SPO 中创建了一个 Web 部件,它通过使用 OAuth 2 并使用 Yammer 按钮登录,除了那些边缘情况,我们希望避免使用管理上下文导出所有数据。
    • @AndersNielsen 我同意今天的 API 不能满足您的需求,但我认为人们理解需要改进。目前,其他项目被优先考虑,所以这不是短期内会发生的事情。在我看来,Yammer 与完整的 Office 365 开发人员平台集成会更好,因此我们必须等待所有客户迁移到 Office 365 身份和“1 个租户:1 个网络”状态。请通过yammer.uservoice.com 提交想法,以便他们可以与其他产品请求一起跟踪并提高对功能需求的认识。
    • 再次感谢@BrianLyttle 回来讨论这个问题。我一定会使用 Yammer 用户语音。祝你有美好的一天。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多