Twitter's REST API returns a in_reply_to_status_id value for tweet statuses, yet the Search API does not.
What puzzles me is, if you search using the http://search.twitter.com/ webpage directly, tweets that are in reply to another tweet contain a "Show Conversation" link, but when searching using the API directly, there doesn't seem to be any data suggesting that a conversation exists (with JSON, at least).
How does this search page know which tweets are part of a conversation, and what would be the best way to emulate this behaviour (JSON preferred) in a rate-friendly way? I imagine I would have to do additional calls or something...?
related_results is officially dead along with the v1 API. It appears official Twitter apps use a call to /1.1/conversation/show.json?id=___ as mentioned here https://dev.twitter.com/discussions/17647 however it appears to be blocked from non-Twitter clients.
Just check the JSON field "to_user", which contains screen_name of the #replied person. If its null, you can assume its not a reply. You could also check, if the tweet string starts with a #username, which
http://search.twitter.com/search.json?q=%40aplusk
When you use the search.twitter.com, look for a field name in_reply_to_status_id This contains the original status_id to which this tweet was a reply. Next, there is a currently unsupported/undocument api call to get the whole conversation:
https://api.twitter.com/1/related_results/show/169145505824256000.json?include_entities=1
The value (169145505824256000) is the status_id you want to retrieve the conversation for.
An update on this as I was just faced with the same problem. The Twitter v1.1 API should now return valid in_reply_to_status_id values. But the unsupported v1 related_results has now gone forever.
You can see information about this, and some suggestions about using the streaming API, at https://dev.twitter.com/discussions/11292
Related
Does anyone know of a solution for checking if a tweet has replies or not, without checking the reply_count field of the JSON response?
I'm building a crawler and already have a method for scraping a timeline for tweets as well as replies to tweets. In order to increase efficiency I want to find out if a tweet has any replies at all before calling my reply method. I have a standard developer account with Twitter so I do not have access to reply_count.
Looking for this as well. Only way I found was scraping the page (which is against the Terms of Service)
reply-count-aria-${tweet.id_str}.*?(\d+) replies
I have an odd problem with my twitter account. Basically I'm generating tweets automatically via a plugin with my WordPress website. That works but the tweets appear twice. I believe this isn't that the plugin is posting twice but want to be sure and just wondered if theres a way I can see technical details about the origin of a tweet?
In the JSON for each tweet there is a source field that shows the utility used to post the tweet. Example from the REST API documentation:
"source":"\u003Ca href=\"http:\/\/itunes.apple.com\/us\/app\/twitter\/id409789998?mt=12\" rel=\"nofollow\"\u003ETwitter for Mac\u003C\/a\u003E"
Also, check the timestamps for each tweet to see how far apart they're being posted. Twitter checks each tweet against the last status posted, and duplication attempts are supposed to be blocked with a 403 error at the statuses/update.json endpoint. Are your duplicated statuses exactly the same? I'd start to check for the problem by comparing each tweet's JSON and seeing if there are any differences.
I'm trying to develop some code in order to get all the tweets that were generated with certain hashtags, then parse them and finally analyse them. I believe I've already thought and solve the last two parts of this but I'm having some trouble with the first one. I've already read the Twitter Search API documentation but I haven't realised yet how to do this. Can anyone help me?
If you want to retrieve the tweets sent recently, you should use the search/tweets endpoint of twitter' REST API, and mention the hashtag inside q parameter
In case you want to listen to tweets containing the hashtag and receive them in real time, then twitter's streaming API is what you should use (statuses/filter endPoint).
Have a look at the documentation on twitter's website, there's also plenty of information on how to do this all around the web.
How do I know if a specific twitter user is currently online by writing programs? Is there any API or data field in the web page showing this information? Both browsing Twitter webpage and using Twitter app are considered "online".
Although this information is not readily available, you can do a work around. Make use of Twitter's Streaming API: https://dev.twitter.com/docs/streaming-apis/streams/public (have a read through this document).
You'll most likely be using the POST Statuses/filter functionality (read the doc here: https://dev.twitter.com/docs/api/1/post/statuses/filter ), which will give you a JSON object with tweets based on your filters.
Make use of the parameters you'll need to specify in the URL to filter the stream (have a look through this document to learn more about it: https://dev.twitter.com/docs/streaming-apis/parameters ), in your case it'll be the follow parameter. You basically specify the twitter ID of the user you want to follow. Here's a sample JSON result of the streaming API in action https://stream.twitter.com/1/statuses/filter.json?follow=25365536 - this one in particular is following Kim Kardashian. Keep in mind that this will give you:
Tweets created by the user.
Tweets which are retweeted by the user.
Replies to any Tweet created by the user.
Retweets of any Tweet created by the user.
So in order to just stream the tweets of your desired user, you'll have to use a programming language of your choice to parse through the JSON object to find the user that actually sent the tweet (this is a little tricky, you'll have to look through the properties of the JSON object to figure it out). Once you narrow the streaming tweets to just the ones from the user though, you can then have an alert on when new tweets by this user stream and that will tell you if the user is online/using twitter at the moment.
It's not clear what you mean by "online" (browsing twitter.com? Using a Twitter app?), but in any case Twitter doesn't provide such information, thankfully.
I'm afraid such information is limited by Twitter and is not available. However you can put your question on https://dev.twitter.com/discussions and ask its developers. Good Luck
you need get user state first
then filter if around current time
then get ids
they are online
use twitter developer api
I do it for my website
I have seen numerous companies doing like Twitter lotteries where users got to retweet their tweet and then one of retweeters will get the prize or whatever.
I was wondering now how do they get the list of all retweeters or pick the winner?
I checked Twitter API and found only this thing: GET statuses/retweets/:id but it returns maximum of 100 retweeters. Is that the only way?
It looks likes there's a couple services out there doing almost exactly this. A quick google pulls up http://onekontest.com/ and there's a few other Twitter contest services, but they all seem to be different levels of broken since they haven't kept up with changes to the API.
As far as the Twitter API itself is concerned, if you were expecting more than 100 responses, I think using GET statuses/mentions makes the most sense. That API call returns any mentions of a user, and you can pass the flag include_rts to include any retweets of your tweets. Then, if you wanted to list RTs of a specific tweet, you could check the in_reply_to_status_id field in the returned data to see if it matches the original tweet ID. This API call only returns the last 800 status, 200 at a time, so if you expect a bunch of data, you would need to poll the API repeatedly over time to get all the tweets. I imagine services like favstar are doing exactly this, just on a larger scale.
If you're actually looking for code to do something like this, I wrote a sinatra app called twitter-rss-digest which handles querying Twitter over time to track different sorts of queries. It's pretty rough, and doesn't quite handle this specifically, but it might point you in the right direction if you want to code something.
The Twitter API has an endpoint that returns up to 100 retweeter IDs for a given tweet.
Note that for historical reasons, that endpoint only returns up to 100 results and the documentation about the cursor is useless. Twitter refused to fix the situation.
2013 note
That said, the first thread on the Developers site that surfaced in a quick google has #episod, a Twitter employee saying:
You can't likely get to all of them. The data is spread out. Your best bet is to use the REST API to determine many of the users who performed the retweet, but the data will still be constrained.
It's easiest to track retweets as they happen rather than try to find them from the past. Use the Streaming API for that.
I like muffinista's method, but I think if you want a 100% complete list of retweets, simply enable the retweet email notifications and write a script that polls the email box for those matching the subject "retweeted one of your Tweets!" and put the data into a table. Do this right from the start.
The site https://twren.ch/ enlists all the retweeters for a given tweet (note that it only enlists retweeters who are direct followers of the source tweeter.) Nevertheless its probably the only public source available.