how to pull out older messages using before_id

132 views
Skip to first unread message

Kahye Song

unread,
May 30, 2016, 1:20:43 AM5/30/16
to GroupMe API Support
I tried to pull out all messages posted in a group using before_id parameter.
I first get first 20 messages using this command
'curl https://api.groupme.com/v3/groups/' + group_id + '/messages?token=' + access_token

then find the id of the last message and retrive the 20 older messages using this command
'curl https://api.groupme.com/v3/groups/' + group_id + '/messages?token=' + access_token + '&before_id='+ temp_msg_list['response']['messages'][-1]['id']

but both commands return the same messages and other parameters such as limit does not work either to me.
Can someone provide me an example how to work with these parameters?
thanks!

Martin (GroupMe dev)

unread,
Aug 24, 2016, 5:47:04 AM8/24/16
to GroupMe API Support
Seems you're using before_id from wrong message - not from the first one, but from the last one... Which means it returns same messages.
I believe, that oldest message is returned as first item of array - so just replace [-1] by [0] and it should work. Or, to make it even more reliable, find lowest id value from returned messages and use that one.

Regards,
Martin

Dne pondělí 30. května 2016 7:20:43 UTC+2 Kahye Song napsal(a):
Reply all
Reply to author
Forward
0 new messages