Yammer REST API - 在更新之前获取所有消息旧消息,因此无法返回old_than

问题描述 投票:0回答:1

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

例:

在一个完美的世界中,Yammer组中的每个帖子都是同步添加的,而不是被评论或喜欢,我们可以使用参数older_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
}
});

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

有谁知道这个功能是如何用于查询旧消息或我们是否遗漏了什么?

更新

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

yammer
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.