tasianmedia / getVimeo

A simple video retrieval Snippet for MODX Revolution
http://modx.com/extras/package/getvimeo
2 stars 5 forks source link

Added support for API pagination #11

Closed alfs closed 10 years ago

alfs commented 10 years ago

Vimeo allows up to 20 items to be returned in each request. Up to 3 "pages" can be requested, for a total of 60 items.

This patch adds support for requesting more pages if the first one is full.

davidpede commented 10 years ago

Thanks for your suggestion Alfs, looks a good addition. Were short on time to test this at the moment but will get to it asap.

davidpede commented 10 years ago

Have tested the PR and there was an issue with the while loop requesting 'page 4' from the API when searching channels with more than 60 videos.

$VIMEO_MAX_ITEMS_PER_PAGE on page 3 would return 20 so the loop moves on to 'page 4' which returns a 403 error.

I have added line comments to your commit. Please review and if happy update the PR for merging.

Thanks again

alfs commented 10 years ago

Yes; however the limit may be increased or reduced in the future by vimeo.

Thinking about it, a better option would be to fetch the next page pages as long as 20 items are returned, and break ( when < 20 items are returned or return code != 200 ). And if return code is e.g. 403, an error message should be emitted, since 60 items are returned, but there are likely more items in the channel that are not shown.

But for now I think the patch is fine, at least 3 times better than the original ;)