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

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

Related

How to get the most recent tweet of many users

I have a list of twitter user_ids. I want to get the most recent tweet of each of them.
There is a search/tweet.json api in which you can give multiple user ids separated by OR as follows:
https://api.twitter.com/1.1/search/tweets.json?q=from%3ATwitterEng%2BOR%2Bfrom%3ATwitter&result_type=recent
This query finds the recent tweets from TwitterEng or Twitter user_ids.
Now, there is a possibility that the API returns only the tweets from TwitterEng since those were more recent.
How do I ensure that I get one tweet from both the users?
There is the user_timeline API that will give the tweet for the given user_id. But I have a lot of user_ids and cannot make calls to this API for all those ids.
Is there a way of achieving this?
Thanks in advance for your replies
Try this ;)
There are two ways to get recent tweets of multiple users:
Get all tweets and filter for the users you want to get the tweets form;
Get tweets for individual user and use the recent tweets based on the tweet posted; with this case you can also mention the from and since parameters while querying twitter api to get tweets between this time bound;
There is no direct endpoint to get recent tweets for multiple users;

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.

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).

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

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.

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

Resources