How do I get the retweet_count of a given tweet WITHOUT user interaction? - twitter

I have a list of tweets that are using a hashtag I made. I'm getting these tweets using the search api. All I want is to get the number of retweets. I DO NOT need to post on their behalf. It seams ridiculous that I would need to have every single user login to my site, login to twitter and approve my application via OAUTH for EVERY TWEET IN MY LIST. There's gotta be a way to get that number without the need for oauth.
I tried getting it directly from the search api, but that's not consistently there. I've tried https://api.twitter.com/1/statuses/show/275729088709283840.json but that doesn't work, for some reason. Is there anyway to do this extremely simple task without going down the asinine road of user-interaction?

You have to create a background-process that uses the stream API. Phirehose is a php library that is set up to do this: https://github.com/fennb/phirehose

Related

Add a larger number of block users via one Twitter Api request

I just learn about Twitter for couple of days. I 'm facing a problems in building an app that add a large number of users to block list via Twitter Api (POST blocks/list ). But this Api is only work with one user per request, using it will lead to 'API RATE LIMIT'. That I want here is a method that can add a lot of users to the block list via one request Can anyone help me overcome this problem ? Thank and best regards. Like this site http://blocktogether.org/
You're getting two things confused.
There is GET blocks/list which allows you to receive a list of a blocked users.
On the other hand POST blocks/create allows you to block users from your twitter account. I believe that's the one you're wanting.
Either way they're both rate limited and you'll need to send multiple requests to the twitter API in order to reach whatever number you're looking into adding. As of now, until twitter decides to change it, it's only 1 user at a time.

How to find out if a user has actually Tweeted?

I have a website which allows the user to tweet using a specific hashtag, would their be anyway to actually find out if the user has really tweeted.
I was thinking of looking at the timestamps and just working out the difference between right now and when the last tweet was made but that's not really professional.
I know Facebook allows you to do this quite easily but I'm struggling to figure out the best solution.
any ideas?
Regards
Retrieve the tweets of the user in question
Scan the text of each tweet, looking for your hashtag.
If you know when they visited your website, compare the time of the visit to the time of the tweet.
If you need to ensure the users tweets, then tweet for the user by requesting authorization and then tweeting via the API. This will still not stop the users from deleting the tweet.
If you plan any reward scheme, you won't be able to force users to keep the tweet (and probably the twitter API ToS forbid such things).
You want to use the Twitter STREAM API. One of the public stream is the Filter Stream.
This stream give the possibility to specify keywords/hashtags that you want to follow in live.
You can simply track the hashtag that you want and then you will receive in live all the tweets posted with your hashtag.
You can then simply check the json property user and compare the id/screen_name to the user you want to identify.

Finding Twitter users with follower count = MAX_FOLLOWER

I have been looking at finding Twitter users with followers more than MAX_FOLLOWER (any number set up by programmer).
I visited the twitter API and found I can search via q="keyword" but could not find any way where I can have a search in API using followers_count >= MAX_FOLLOWER
Tried looking some methods at https://dev.twitter.com/tags/finding-users as well but they were not really helpful as I could not find exactly what I am looking for.
Even for oAuth stuff, I tried creating a URL after creating a signature but still not able to consume that.
From the signature base string if I copy the url and decode it for addreess bar and send the request it says page does not exist. So looks like I am not even able to consume the services properly.
My end result will be I want a list of users who have followers_count more than MAX_FOLLOWER and then I can do a new query on those users.
I have been trying this stuff for over 4-5 hours and totally clueless where I am doing wrong or how to proceed. Read a lot of twitter api docs but nothing I could find was useful in my case.

How do I know if a specific twitter user is online or not?

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

How to get a list of all retweeters in Twitter?

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.

Resources