Вопрос

I am trying to get all the messages from a particular group. I am getting the json feed back. The only problem is, its returning only 20 messages. Is this set as default or something. Is there any way by by which while doing the request, I can specify whether I want all the messages, by default just 20 or even messages posted between the start and the end date?

My RestApi call is:

https://www.yammer.com/api/v1/messages/in_group/[id].json

From Yammer Developer Documentation <

Autocomplete: 10 requests in 10 seconds.

Messages: 10 requests in 30 seconds.

Notifications: 10 requests in 30 seconds.

All Other Resources: 10 requests in 10 seconds.

These limits are independent e.g. in the same 30 seconds period, you could make 10 message calls and 10 notification calls. The specific rate limits are subject to change but following the guidelines below will ensure that your app is not blocked.>>

I have tried using limit as the parameter to change the number of message more than 20. But it doesnt seem to be working?

Is this problem because of Rate Limit. If not, what's the problem?

Это было полезно?

Решение

Official documentation from Yammers Developer documentation


Messages - Viewing Messages

Endpoints:

1) All public messages in the user’s (whose access token is being used to make the API call henceforth referred to as current user) Yammer network. Corresponds to “All” conversations in the Yammer web interface.

GET https://www.yammer.com/api/v1/messages.json

2) The user’s feed, based on the selection they have made between “Following” and “Top” conversations.

GET https://www.yammer.com/api/v1/messages/my_feed.json

3) The algorithmic feed for the user that corresponds to “Top” conversations, which is what the vast majority of users will see in the Yammer web interface.

GET https://www.yammer.com/api/v1/messages/algo.json

4) The “Following” feed which is conversations involving people, groups and topics that the user is following.

GET https://www.yammer.com/api/v1/messages/following.json

5) All messages sent by the user. Alias for /api/v1/messages/from_user/logged-in_user_id.format.

GET https://www.yammer.com/api/v1/messages/sent.json

6) Private messages received by the user.

GET https://www.yammer.com/api/v1/messages/private.json

7) All messages received by the user.

GET https://www.yammer.com/api/v1/messages/received.json

Parameters:

The messages API endpoints return a similar structure and support the following query parameters:

older_than - Returns messages older than the message ID specified as a numeric string. This is useful for paginating messages. For example, if you’re currently viewing 20 messages and the oldest is number 2912, you could append “?older_than=2912″ to your request to get the 20 messages prior to those you’re seeing.

newer_than - Returns messages newer than the message ID specified as a numeric string. This should be used when polling for new messages. If you’re looking at messages, and the most recent message returned is 3516, you can make a request with the parameter “?newer_than=3516″ to ensure that you do not get duplicate copies of messages already on your page.

threaded=[true | extended] - threaded=true will only return the first message in each thread. This parameter is intended for apps which display message threads collapsed. threaded=extended will return the thread starter messages in order of most recently active as well as the two most recent messages, as they are viewed in the default view on the Yammer web interface.

limit - Return only the specified number of messages. Works for threaded=true and threaded=extended.


Noted the limit parameter that you can set on your GET request - so based on this documentation if it is correct (I'm not a Yammer Developer but I do use it) you should be able to do

https://www.yammer.com/api/v1/messages.json?limit=50

That is in theory but reading through the documentation there is a section on Search that has

page - Only 20 results of each type will be returned for each page, but a total count is returned with each query. page=1 (the default) will return items 1-20, page=2 will return items 21-30, etc.

Which says to me they are limited to 20 results returned.

UPDATE

After testing this with https://www.yammer.com/api/v1/messages.json?limit=50 and it not returning 50 messages but doing https://www.yammer.com/api/v1/messages.json?limit=5 will return only 5 messages I would say that Yammer restrict the number of messages to 20 Also after reading through the documents a bit more I read

For example, if you’re currently viewing 20 messages and the oldest is number 2912, you could append “?older_than=2912″ to your request to get the 20 messages prior to those you’re seeing"

This says to me that they will only return a max of 20. So I think you are stuck with 20 messages at a time.

Hope this helps.

Другие советы

You need to use Parameters: The messages API endpoints return a similar structure and support the following query parameters:

older_than - Returns messages older than the message ID specified as a numeric string. This is useful for paginating messages. For example, if you’re currently viewing 20 messages and the oldest is number 2912, you could append “?older_than=2912″ to your request to get the 20 messages prior to those you’re seeing.

newer_than - Returns messages newer than the message ID specified as a numeric string. This should be used when polling for new messages. If you’re looking at messages, and the most recent message returned is 3516, you can make a request with the parameter “?newer_than=3516″ to ensure that you do not get duplicate copies of messages already on your page.

threaded=[true | extended] - threaded=true will only return the first message in each thread. This parameter is intended for apps which display message threads collapsed. threaded=extended will return the thread starter messages in order of most recently active as well as the two most recent messages, as they are viewed in the default view on the Yammer web interface.

limit - Return only the specified number of messages. Works for threaded=true and threaded=extended.

Example : GET https://www.yammer.com/api/v1/messages.json?older_than=2912 while older can be ID of message number 20 and so on you can get 20 by 20

I solved by requesting subsequent pages in a recursive manner.

You can simply increase the page parameter until the response is empty, or update the older_than parameter until the property meta.older_available is false.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top