What is the best approach to working out if I have retweeted a tweet from another user, via the Twitter API? - twitter

So, I am currently working on an application that allows me to search journalists and view their contact details including, among other things, their latest tweets.
Calling the Twitter API is no problem at all, and I have a list of tweets for the current journo showing up fine. However, I am trying to decide the best approach to seeing if I (the user logged into our application) have retweeted any of the journo's tweets, so that I can display the tweet as having been retweeted.
Looking at the API documentation, I am looking into the following options:
1 - Use /statuses/retweeted_by_me to get the list of tweets that I
have retweeted, specifying max_id to be the highest id from the
list of tweets for the journo I am looking at. What I am not sure of
here is if the max_id is going to limit by the max id of my tweets or
the max id of the retweeted tweets.
2 - Use /statuses/:id/retweeted_by for each of the journo's tweets to
get a list of all the users who have retweeted that tweet and to check to
see if my user is in the returned list of users. Downfalls of this is that there
could be thousands of retweeters and I can only return a maximum of
100 at a time. That could mean a lot of requests just to find if I
retweeted one tweet. This also means that I need to do this for each
of the journo's tweets as opposed to getting the list of all my
rewteets above.
3 - Use /statuses/retweets/:id to get a list of the retweets for
each of the journo's tweets. This option has the same limitations as
#2.
I'm currently leaning towards #1, however, I'm not sure as yet if this will work. I need to do some more investigation. In the mean time, my question to you is:
What is the best approach to working out if I have retweeted a tweet from another user?

Ok, so I must have been having a brain fart moment when looking into this yesterday. It occurred to me this morning that you can simply make an authenticated call to /statuses/user_timeline which will set the retweeted property to true if you have retweeted that tweet.
Simples.

Related

Measure retweets and top influencer

According to Twitter API, it returns up to 100 of the first retweets of a given tweet.
What is the best way to measure number of retweets, when the amount
is higher than 100?
What is the best way to find top influencer of my tweet (Person, who retweeted my tweet, and he has the highest number of retweets)?
I found the answers:
Twitter API Get Status provide amount of retweets: "retweet_count"
If you want to get all retweets you should periodically query Twitter to get retweets.
Note: In spite, Twitter API allows to return up to 100 retweets, it usually return only latest retweets during last random timing frame.
New style retweets track only first level. Example:
#bob: My Awesome application http://bit.ly/1234
#alice: RT: #bob My Awesome application http://bit.ly/1234
But if #eve RT #alice retweet, the message will be similar to alice's and she won't be mentioned in it.
#eve: RT: #bob My Awesome application http://bit.ly/1234
The old style was (not in use anymore): RT: #alice: RT: #bob My Awesome application http://bit.ly/1234
Important!
There is some Twitter API limit https://dev.twitter.com/docs/rate-limiting/1.1. OAuth-enabled application could initiate 350 GET-based requests per hour per access token.
If you want to work with the Instagram API, the method suggested above will work really well.
I you do not want to work with the API, many free social media tools are available that will do this stuff for you. Search "twitter analytics tools" and you will find an array of options. Crowdbabble has a free trial that will let you track your retweets and the top influencers who follow you -- you can sort your followers in a table by the number of followers they have.

How can I get all action (retweets and favorite) happened on a certain user tweets and who did this actions?

I am creating a competition for my twitter followers, so any one will retweet any of my tweets will gain 15 points and any one favorite any of my tweets will gain 10 points.
How can I use the APIs to get all action (retweets and favorite) happened on a certain user tweets and who did this actions?
Thanks,
Okay so you want to use the make oAuth calls to the twitter API. You want to start by getting the tweet details
https://dev.twitter.com/docs/api/1.1/get/statuses/show/%3Aid
That will return data about that tweet which will include how many times its between retweet or favourited. Then you use the following to API calls to get details about retweets and favourites.
https://dev.twitter.com/docs/api/1.1/get/statuses/retweets/%3Aid
https://dev.twitter.com/docs/api/1.1/get/favorites/list

Twitter messages on website with votes

I am not sure how it is done, therefore my questions below:
I would like to ask folks on Twitter for a suggestion on a particular topic. Can I tell them to use certain hashtag and have all comments with that hashtag posted on my site?
Do I just pick a hashtag or does it need to be created somehow?
Can I have users on my site rate those suggestions? In that case, would I need to somehow grab twitter message and store locally?
Just trying to understand the process in order to implement it.
Hashtags don't have to be created - just use it in tweet.
In order to get all tweets with particular hashtag, use search API: https://dev.twitter.com/docs/api/1/get/search and search for this hashtag. You should save all relevant tweets (twitter search is not reliable on old tweets).

Twitter API bug - Tweets provides the wrong User_id. Work arounds?

I'm looking for a workaround to this Published Twitter API bug: http://code.google.com/p/twitter-api/issues/detail?id=214
When you fetch tweets, the tweet returns an incorrect User_id. However it does provide you with the correct Screen name.
My Goal is to use the API to do 2 things:
Fetch all the followers of my twitter account, this is trivial with the ruby script:
myfollowers = Twitter.follower_ids("justinzollars") (twitter gem)
corresponding to this api call: https://dev.twitter.com/docs/api/1/get/followers/ids
Save only tweets from an individual user. https://dev.twitter.com/docs/api/1/get/search
The problem is the first api call returns user_ids, and the tweets search call returns from_user_id_str (user_name). I don't want to make tens of thousands of api calls, asking twitter for the user_id of each from_user_id_str that is returned from the tweets search api call.
How can I efficiently solve this problem?
The Search API isn't really the best tool for the job as far as retrieving a specific user's tweets is concerned. You should use the User Timeline for that task, which doesn't suffer the Search API's mismatched user ID issue: https://dev.twitter.com/docs/api/1/get/statuses/user_timeline
If you were using the Search API though, the most efficient pattern for converting screen names in Search to user ids on Twitter would be to use bulk user lookup, which would allow you to convert roughly 100 screen names to fully hydrated user objects (complete with the "real" user id): https://dev.twitter.com/docs/api/1/get/users/lookup

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