Require your help for Twitter Search API - twitter

As there are 2 response format(Atom and Json) from Twitter search api, i am trying to fetch the twits(Json format) by using the URL:[http://search.twitter.com/search.json?q=pareshmayani], but you know it is returning only 1 page with 15 twits at a time(and yes its as per the twitter search API documentation) same as the below image:
1
But what if i want to fetch 2nd page of twits, i know i can use page querystring value such as http://search.twitter.com/search.json?q=pareshmayani&page=2, but when i use it, it returns me the below output:
Problem: So As you have noticed the above response, it should return 2nd page of 15 twits in response. Please give me suggestions if i am doing something wrong to fetch 2nd page of twits.
Thanx,
Paresh

There is only one page of results.
If you search for a popular term, like cheryl cole, you will see a 'next_page' field returned in the JSON. This field contains a query string to retrieve the next page.

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.

Twitter API and operator

I want to make a simple Twitter API get using JSON. The idea is to get only the posts from a known corporation (say BigCorporation) sent to the main corporation (#BigCorporation). The idea is to just get the main annoncements and filter out anytime the BigCoporation answer a question from a follower (i.e. BigCoporation tweets: #someguy we are anwering your question)
So Tweets from:BigCoporation with the #BigCorporation
I came up with this API get but I seem to get both #BigCorporation or from:BigCorporation tweets. I want only the Tweets that are #BigCorp AND from:BigCorp
http://search.twitter.com/search.json?q=#BigCorporation&q=from:BigCorporation&result_type=mixed
Your search query is malformed.
It should be:
http://search.twitter.com/search.json?q=#edent%20from:edent&result_type=mixed
That will show you all the tweets I have sent which contains the string "#edent"
You can use this URL :
https://api.twitter.com/1/statuses/user_timeline.json?screen_name=BigCorporation&exclude_replies=true
The REST method GET https://api.twitter.com/1/statuses/user_timeline.json returns the most recent tweets (20 by default) of a user whose username (here BigCorporation) is in the parameter screen_name. When set to true (or t or 1), the exclude_replies parameter excludes the tweets that you want to avoid ("#someguy we are anwering your question").
You can visit this page on the Twitter API website for further details.

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.

Twitter API - Display all tweets with a certain hashtag?

How would I go about displaying tweets that contain a certain hashtag using the Twitter API? Thanks
I'd also like to know if there is a way to get all tweets from a certain hashtag in a separate file, also the ones that don't show up in your feed anymore. I suppose that's what the earlier question was about, too.
This answer was written in 2010. The API it uses has since been retired. It is kept for historical interest only.
Search for it.
Make sure include_entities is set to true to get hashtag results. See Tweet Entities
Returns 5 mixed results with Twitter.com user IDs plus entities for the term "blue angels":
GET http://search.twitter.com/search.json?q=blue%20angels&rpp=5&include_entities=true&with_twitter_user_id=true&result_type=mixed
UPDATE for v1.1:
Rather than giving q="search_string" give it q="hashtag" in URL encoded form to return results with HASHTAG ONLY. So your query would become:
GET https://api.twitter.com/1.1/search/tweets.json?q=%23freebandnames
%23 is URL encoded form of #. Try the link out in your browser and it should work.
You can optimize the query by adding since_id and max_id parameters detailed here. Hope this helps !
Note: Search API is now a OAUTH authenticated call, so please include your access_tokens to the above call
Updated
Twitter Search doc link:
https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets.html
The answer here worked better for me as it isolates the search on the hashtag, not just returning results that contain the search string. In the answer above you would still need to parse the JSON response to see if the entities.hashtags array is not empty.

Resources