How to get maximum number of tweets on an user - api

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.

Related

Unpredictable soundcloud api tracklist

I need to get whole user's tracklist by SC api.
Before I use the next link format:
https://api.soundcloud.com/users/{user_id}/tracks/?page_size=200&linked_partitioning=1&client_id={app_id}
But it has stopped to work correct recently.
Changes:
limit has been decreased by SC from 200 tracks to 50;
returned tracks have become random (eg user has 300 tracks, but request above returns 54 tracks and link to the next page of tracks where fields "offset=50&limit=50" are appearing;
when I change field "page_size" from 200 to 50, SC returns only 18 tracks).
Also I've tried to use fields "offset" and "limit" instead of "page_size" but it has worked incorrect, too.
How I can get whole user's tracklist?
You need to parse the response and read next_href then change the url to the next_href value.
It's better to do this as a loop until there is no more next_href
Some recent updates on pagination from the API can be found below. You need to rely on the cursor rather than offset
https://developers.soundcloud.com/blog/pagination-updates-on-our-api

What is the proper way to format a GET request to retrieve all media items of the Instagram user "self"?

Looking at https://www.instagram.com/developer/endpoints/users/ I have gathered that calling https://api.instagram.com/v1/users/self/media/recent/?access_token=ACCESS-TOKEN will return "the most recent media published by the owner of the access_token."
In sandbox mode I understand that I will receive a maximum of 20 media items from this call. I also realize that the response code has a pagination object that I can use to retrieve up to 20 more media items (see below)
"pagination": {
"next_max_tag_id": "1387272337517",
"deprecation_warning": "next_max_id and min_id are deprecated for this endpoint; use min_tag_id and max_tag_id instead",
"next_max_id": "1387272337517",
"next_min_id": "1387272345517",
"min_tag_id": "1387272345517",
"next_url": "https://api.instagram.com/v1/tags/cats/media/recent?access_token=xxx&max_tag_id=1387272337517"
}
These are the listed parameters of this Request.
PARAMETERS
ACCESS_TOKEN A valid access token.
MAX_ID Return media earlier than this max_id.
MIN_ID Return media later than this min_id.
COUNT Count of media to return.
My question is: Is there a way to structure my GET request in a way that returns all media items from a single call? I understand that this is not possible in sandbox mode, given a user with more than 20 media items. If possible please provide a detailed explanation of the COUNT parameter.
I imagine a possible GET request would look like https://api.instagram.com/v1/users/self/media/recent/?access_token=ACCESS-TOKEN?COUNT=X
Thank you. <3
When you go live mode you can use the count= param to get more than 20 in one API call, however I have noticed that count=33 is the maximum you can get for this API call, even if you anything more than 33, it only returns 33.
You still have to use the pagination in JSON response to get the next set of media items, easiest way is to use the pagination.next_url to make API call and get next set of media items

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

Is the checkin object's type=mayorship notification appears fickle?

I have some questions about 4sq's API.
Chceckin object obtained by checkins/add endpoint's response sometimes has mayorship field and at other times not.
And mayorship's checkins count field seems not reliable (often appears count 0, but actual count is 2).
Is it so?
thanks.
The notification only contains mayor information if the user is somewhat close to being able to claim the mayorship.
As for incorrect checkin counts, you'll need to provide an example response for us to be able to debug.