Twitter API not showing old tweets? - twitter

I have a problem with twitter API. I tweeted in the past (around 400) but recently I haven't tweeted anything. When I try to fetch tweets by me using the twitter api, there are no results. How can I retrieve the older tweets?

Twitter doesn't return tweets older than a week through search api. Take a look at the limitations section from the below link:
https://dev.twitter.com/docs/using-search

I have the same problem as you, so after see that Twitter Web Search works I've started to implement my own solution, you can see on my GitHub. It is implemented in Java, but it will make a post on my blog to explain how to do in other languages. I've downloaded tweets without any problems, my last test I parse more than 600k within 2014 from some specific users.

You can use the REST API resource GET statuses/user_timeline to retrieve the most recent 3200 tweets from any public timeline.

This is possible in Twitter web search portal but not through their API. Bummer
https://twitter.com/search-home

This elaborates on #bennett-mcelwee 's answer where getting up to 3200 most recent user tweets can be done in series of API calls. Currently the max # of tweets you can get by a user in 1 request is 200, using the GET statuses/user_timeline API call. To get all tweets a user has posted on their timeline do the following:
STEP 1
Make a GET call to this endpoint passing parameter count=200.
STEP 2
From the returned data in step 1, get the ID of the last tweet
Make the same GET call but this time pass in parameter max_id= followed by the ID of last tweet returned form the first call, or -1. So for example max_id=9987999
STEP 3
Repeat step 2 until you don't get any new(older) data.
For my purpose I was able to do this in Ruby using https://github.com/sferik/twitter
Once a client object is instantiated, it's as simple as:
tweets = client.user_timeline('foobar', count: 200)
max_id = tweets.last.id - 1
tweets << client.user_timeline('foobar', count: 200, max_id: max_id)
From here you get idea and it's fairly trivial to write a loop until you've gotten all the tweets you can grab from the API.

Related

Get all tweets,all following and all followers from 2015-12-01 to 2016-03-20 using twitter api

i want to get all tweets,all followers and all followings from 2015-12-01 to 2016-03-20 using twitter api.
when i use following code it always give me latest 20 tweet,i am passing the 'until' parameter to get all tweets but i want to pass date such as "from 2015-12-01 to 2016-03-20".
how is this possible to get twitter data from 2015-12-01 to 2016-03-20.
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
$twtrdata = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" . $twitteruser . "&until:2016-03-01");
There is no until-parameter for the Twitter API user_timeline.
The Twitter API is pretty limited, for example, using user_timeline will only return a maximum of 200 tweets at a time, and you will have to call it multiple times to get all tweets. There is a created_at-attribute connected to the tweets returned that you can use to filter out the tweets you want within a time frame, but you'll still have to run multiple requests to get all of them, probably. In addition to the 200 per request limit, there is also a restriction in place so that you cannot fetch more than the 3200 most recent tweets of a user.
For more info on this API call, and the rest of the Twitter API, have a look at Twitter's documentation.

yt:statistics / view count not returned with v2 api

I am not able to get yt:statistics and corresponding view count using youtube v2 api
Search URI:
http://gdata.youtube.com/feeds/api/videos/-/park/competition?orderby=viewCount&max-results=50&v=2&format=5&fields=entry(title,content,media:group,yt:statistics,yt:rating,gd:rating)
When I print the feed and look for statistics, I can not found it. I believe I was able to get it until last week.
I use PYTHON gdata lib to send/receive requests. It looks like for some feeds I am getting statistics. Does it not come for every feed??
Any pointers??
UPDATE: Similar observations for yt:rating.
Is there a minimum guarantee that yy api provides for statistics/rating?
Without a minimum guarantee, does it not become un-reliable?
Have you tried using the YouTube-Analytics API?
Not sure what the equivalent call in the Python library would be - but for example, this url will get the top viewed videos:
https://www.googleapis.com/youtube/analytics/v1/reports
?metrics=views
&dimensions=video
&max-results=10
&sort=-views
&start-index=1
&start-date={first date of interest}
&enddate={last date of interest}
&ids={your channel id}
You should be able to use the same OAuth token that you're using for the YouTube Data API v2.

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.

Twitter: Number of tweets OR get more tweets

I would like to know how can I get all tweets from a certain hash tag?
I am currently using the following code:
xhr.open("GET","http://search.twitter.com/search.json?q=%23PrayForJapan");
This only returns me 15 tweets. Does anyone know how to make it return more?
Also, I have got a code to get me the tweets of a certain screen name, this only returns 20 tweets, how can i ask the following 20 tweets?
The code i used for that is:
xhr.open("GET","http://api.twitter.com/1/statuses/user_timeline.json?screen_name=Eminem");
I'm using titanium to create this, but I don't think that is an issue?
Thanks!
You can usually add count=x as parameter to the query string to get up to x tweets (for the search api it seems to be rpp). Query string parameters are added to the base url via ? and each individual parameter is then separated by & as in http://api?user=1&count=4
Most of the time, it is better though to remember the last tweets and then add ?since_id=x as this way you only get tweets you did not see before.
Have a look at the api documentation.

Resources