Ignore the max_id item in Twitter API when getting resource - grails

I'm developing Grails app that getting resource from Twitter restful api.
When I get the resource having many items, it may have many pages. I used parameters max_id for getting the next page but the results always included the item that is max_id I inputed.
Could someone tell me the way to ignore the max_id item?

You can use page parameter instead of max_id, and set the number of items you want to get in one page through count parametter.
For example, you can get 10 items in page 2:
TWITTER_API_URL?count=10&page=2
Note: the maximum items you can get in one page is 200

Related

On third page not getting next page token google place api?

On third page not getting next page token google place api?
I am using Google place text search API in my Ruby on rails application, everything is working fine but after third page I am not getting any next page token so for every text search I am getting only 60 result. Is I am missing something please suggest any help would be appreciable. This happen for every text.
My request for first page :-
https://maps.googleapis.com/maps/api/place/textsearch/json?key=#{my_key}&query=#{my_query}
My request for other page with token:-
https://maps.googleapis.com/maps/api/place/textsearch/json?key=#{my_key}&pagetoken=#{next_page_token}
And usually I am searching on google it show 100's of result for same place text. How can I get result more than 60.
This is intended behavior for Google's Places API, as you can only get up to 60 places, split across 3 pages (3 queries). This is why there is no next_page_token on the third page.
By default, each Nearby Search or Text Search returns up to 20
establishment results per query; however, each search can return as
many as 60 results, split across three pages. If your search will
return more than 20, then the search response will include an
additional value — next_page_token.
Reference here.

Paginating in youtube API V3

I am new at youtube API V3 now I can get the videos of some user and display them at my site but now when the result is more than 50 video I want to make a paging for them lets say that my result is 240 so I have 5 pages now how I make the request for page number 4 with out go through links 1 , 2 or 3
Here is my list request:-
https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=UUdxi8d8qRsRyUi2ERYjYb-w&key={myKey}
there are a page token that allow me to go through the links but that mean that I must to use next and prev requests
so is there any way to load page 4 direct ?
There is no way to load a specific page directly you need to call the API with the nextPageToken for each page (so 4 times in your example).
I do not recommend this approach but include it for completleness as it provides a direct solution to the question whereas the other answer provides alternatives.
Youtube seems to use the same pageTokens regardless of playlist or date of access. E.g., the pageToken for the 2nd page is always CDIQAA, for the 3rd page CGQQAA, etc.
These aren't guranteed to always remain the same, but based on stackoverflow posts from as early as 2014, it hasn't changed in a long time, so it's a reasonable assumption.
So you could make the request for the first five pages as you normally do, then persist the page tokens (e.g. in a local cache). Then whenever you need e.g. the 240th item in the future, simply look up the 5th page token (which happens to be CMgBEAA) and access that page directly.
Here are the 1st 9 page tokens:
1 <blank>
2 CDIQAA
3 CGQQAA
4 CJYBEAA
5 CMgBEAA
6 CPoBEAA
7 CKwCEAA
8 CN4CEAA
9 CJADEAA

Youtube - How to browse all channels in a given category?

For example, there are 884 channels under beauty and fashion, however, Youtube only shows about 50 of them. How do i get the complete list? Either through API or web.
https://www.youtube.com/channels/beauty_fashion
Thanks,
The first thing to do is to get the Guide Category ID that you're interested in. If you do a call to
https://www.googleapis.com/youtube/v3/guideCategories?part=snippet&hl=en&regionCode=US&key={YOUR_API_KEY}
where the hl parameter is the language and the regionCode is the country code (as some categories may not be available for particular languages/regions), you'll get a list of all the categories and their IDs.
For example, that call tells us that the Beauty and Fashion guide category ID is GCQmVhdXR5ICYgRmFzaGlvbg. With that ID, we can then do a channels list call:
https://www.googleapis.com/youtube/v3/channels?part=snippet&maxResults=50&categoryId=GCQmVhdXR5ICYgRmFzaGlvbg&key={YOUR_API_KEY}
This will give you 50 channels in that category. It will also give you a 'nextPageToken' ... you do the same request as above, but add "&pageToken={WHATEVER THAT NEXT PAGE TOKEN VALUE IS}" to get the next 50, and so on.
You can retrieve up to 500 that way ... that's the limit through the API.
Note that all of these calls require an API key from console.developers.google.com
Visit this site: http://www.channelcrawler.com/
You can list the channel in selected category and many other options.

Why is the twitter list API not returning the correct number of results?

I'm using the twitter List API to get tweets from a set of accounts that I've added to a list. However, I'm noticing that for some reason I'm not receiving the correct number of tweets in the response from twitter. Here is my URL
https://api.twitter.com/1/lists/statuses.xml?list_id=68707107&per_page=30
I'm clearly asking for 30 results there, however if you just type that into a web browser you'll see it does not return 30 results. Does anyone know why this is?
Thanks!!
The per_page attribute it's an "up to" value. If you use the since_id you may get better results. And the pages in the api are being deprecated as you can read in the doc.
Work your solution using the since_id and max_id arguments in the api.
Check https://dev.twitter.com/docs/working-with-timelines
Check this answer: GET lists/statuses per_page returning unexpected results
Twitter may be limiting the number of tweets in requests to 20 so you could try downloading 20 and then load the next 10 after that.

Twitting URLs with # in them and getting their count

The goal here is to be able to "tweet" a link of the format
www.example.com/page.aspx#1, and get the number of "tweets" for that link... Basically, what the out-of-the-box Twitter button does for any normal link.
Reason for this is because the page displays different content based on the ID after the #, so there is a need to count which specific item was "tweeted" and how many times.
I tried passing that URL to the Twitter service to get the count (http://urls.api.twitter.com/1/urls/count.json?url=), but the JSON object I get back only has
{"count":0,"url":"www.example.com/page.aspx/"}.
The link for the Twitter button looks like this (done in JavaScript)
var twtLink = 'http://twitter.com/intent/tweet?url='+encodeURIComponent(twtUrl)+'&counturl='+encodeURIComponent(twtUrl);
Any suggestions would be appreciated.
Thanks!
Twitter actually re-interrupts all URL's with their own custom t.co wrapper. This is good news for your use case. You can use these unique t.co links with the counter API.
If you include the attribute &include_entities=1 to the end of some Twitter REST API calls you get back expanded info including the URL's in the tweets. You will see the original URL as well as the shortened URL version. Pass the shortened URL version into the counter API.

Resources