Google Plus API nextPageToken error - google-plus

We are iteratively performing queries against the Google Plus API. They all look like the following query, where the pageToken value is changed on each iteration, updated with the nextPageToken from Google's response to the previous query.
https://www.googleapis.com/plus/v1/activities?maxResults=20&orderBy=recent&query={OUR QUERY}&pageToken={GIVEN PAGE TOKEN}&key={OUR API KEY}
The Google+ reference indicates that the nextPageToken should be absent from Google's response on the last page of results. However, this is what we experience: once we've apparently reached the last page of results, we keep receiving nextPageToken values along with an empty result set in the items field; the nextPageToken value changes on each iteration. This pattern repeats itself several times until one of the nextPageTokens finally results in a 500 error.

This is a known bug. You should star the issue to show your interest in having it fixed.

Related

Token to the next page in pagination API

I have a list of records on the server sorted by a key and use pagination API to return list of segments one by one. Since items can be inserted in the middle of the list, I return the first key of the next page as a pagination token that has to be passed to get the next page.
However, I've found that DynamoDB uses the last key of the current page instead for querying API, which is null if the next page does not exist.
Question:
What are pros and cons between using the last item of the current page and the first item of the next page as a pagination token?
N.B:
As for me returning the first item is more intuitive since it's null only if the next page does not exist.
Using the "last item of the current page" (LICP) is better than using the "first item of the next page" (FINP) because it deals better with the possibility that, in the meantime, some item is inserted between these two items.
For example suppose the first page contains 3 alphabetically ordered names: Adam/Basil/Claude. And suppose the next page is Elon/Francis/Gilbert.
Then with LICP the token is Claude, while with FINP the token is Elon. If no new names are inserted, the result is the same when we get the next page.
However, suppose we insert the name Daniel after getting the first page but before getting the second page. In this case, when we get the second page with LICP we get Daniel/Elon/Francis, while with FINP we get Elon/Francis/Gilbert. That is to say, FINP will miss Daniel, while LICP will not.
Also, FINP may consume more computing resources than LICP, since you must retrieve one extra item (4 items, in the above example, instead of only 3).

How to get maximum number of tweets on an user

i have this code
("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$twitteruser.'&count=500'
But it is giving me only 200 records , I found in twitter document that it will give 3200 tweets.Is i am doing wrong what should i do to get that much tweet.
Since there is no page system in twitter 's API, to go throught timelines, you must use the "max_id" parameter.
Here is an helpful link that explains how to work with timelines with nice illustrations: https://dev.twitter.com/rest/public/timelines.
Edit: here is how you do it.
"To use max_id correctly, an application’s first request to a timeline endpoint should only specify a count."
Make your request "https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$twitteruser.'&count=500 (you can put 200).
Then when you get all your data, " keep track of the lowest ID received" and use it as parameter (the same way you do for the count) for your next request. it will give you the 200 next posts with a lower id than the one you specified. Do it again until you reach the end.

YouTube API Search v3 - Start index?

I'm using the YouTube Search API to grab 5 videos per time under a specific keyword. But I've been trying and trying, but couldent find the parameter for the start index. Does anyone know how to add it, so it gets the next 5 videos etc..?
Current URL I have:
https://www.googleapis.com/youtube/v3/search?part=snippet&q=wiz+khalifa&type=video&key=AIzaSyB9UW36sMDA9rja_J0ynSYVcNY4G25
In the results of your first query, you should get back a nextPageToken field.
When you make the request for the next page, you must send this value as the pageToken.
So you need to add pageToken=XXXXX to your query, where XXXXX is the value you received in nextPageToken.
Hope this helps

Is it correct that the Instagram Location/Search endpoint does NOT support pagination?

I have read several postings about the fact that the Instagram API returns only 20 results at a time. In many cases, people have suggested that all you need to do is to use the next URL which is returned in the pagination information. I would be fine with that, but the JSON returned by
https://api.instagram.com/v1/locations/search?
does not appear to have any pagination information. I have seen a posting that says that /media/search does not support pagination. I just wanted to confirm that the same is true for /locations/search. Can anyone confirm?
And if this is correct, does anyone have any thoughts about how you can get a list of all Instagram events in a specific area, rather than just the first 20 or so?
/media/search end point does not have pagination, but you can get next set of 20 pics by using url param max_timestamp, get the created_time of the last photo in api response and apply it as max_timestamp for next url call, it will return the next 20. Thats how I implemented here: http://www.gramfeed.com/instagram/map
for locations/search end point, timestamp does not apply, you can change distance url param and get more results: http://www.gramfeed.com/instagram/places

Google custom search REST number of results (num field)

I'm trying to figure out how to force google custom search to give me back 20 results per page.
I've tried to send this REST request configuring my new Custom Search Engine to:
Standard edition: Free, ads are required on results pages.
https://www.googleapis.com/customsearch/v1?key=AIzaSyCgGuZie_Xo-hOECNXOTKp5Yk7deryqro8&cx=015864032944730029962:5ipe0q27hgy&q=test&alt=json&num=20
IT NOT WORKS!
but
https://www.googleapis.com/customsearch/v1?key=AIzaSyCgGuZie_Xo-hOECNXOTKp5Yk7deryqro8&cx=015864032944730029962:5ipe0q27hgy&q=test&alt=json&num=10
IT WORKS!
But reading documentation at
https://developers.google.com/custom-search/docs/xml_results#numsp
it says that:
Optional. The num parameter identifies the number of search results to return.
The default num value is 10, and the maximum value is 20. If you request more than 20 results, only 20 results will be returned.
Note: If the total number of search results is less than the requested number of results, all available search results will be returned.
Someone has experienced this problem?
PS: I've tried also to send that REST request configuring my new Custom Search Engine to:
Site Search: Starts at $100 per year, ads are optional on results pages.
But nothing has changed no way to obtain 20 results in a request/page
This documentation url has descriptions of each parameter. It also says num is restricted to integers between 1 and 10, inclusive.
https://developers.google.com/custom-search/v1/using_rest#query-params