Get tweet count of shares for multiple URLs with one request - twitter

I know how to get the tweet count of shares for one URL with the following request:
https://cdn.api.twitter.com/1/urls/count.json?url=[URL]
What I don't know is how to get the tweet count of shares for multiple URLs with just one request, maybe something like this:
cdn.api.twitter.com/1/urls/count.json?url=[URL1,URL2,URL3,...]
Facebook already has this functionality:
graph.facebook.com/?ids=[URL1,URL2,URL3,...]
I was wondering if Twitter has this as well.

I don't think is is supported.
Also this URL is not supposed to be available for the public and you shouldn't use it, especially since Twitter plans to shut it down in the near future (this month, I think).
You should look into the the Twitter REST and Streaming APIs instead.
https://dev.twitter.com/streaming/overview
https://dev.twitter.com/rest/public
Twitter says one of these should be used, these are officially supported.
But so far, I haven't found a way to easily query the number of tweets for a URL using these APIs though.

Related

Is there any methods to get the like list of a tweet?

I want to get the complete like list of a specific tweet, but the Twitter API only provided an API that can retrieve the 100 most recent users who liked the specific tweet. I also looked for Twitter crawlers on Github, but they all worked in a user-oriented manner, ie they can only get a list of liked tweets of a user, not a list of liking users of a specific tweet.
I also tried to crawl the list using selenium, but maybe due to my limited skill, it didn't work well. I don't want to spend a lot of time studying selenium and front-end knowledge just to accomplish a simple thing, so are there any open source codes or twitter APIs that can do this?
Yes. This has just been announced in the Twitter API v2.
Previously, you were limited to the 100 most recent Likes or Retweets with these endpoints. We heard your feedback that this was too limiting and have updated these endpoints to now return all results. To retrieve a complete list of Likes and Retweets, you can now use pagination.
Use the v2 Likes lookup endpoint: GET /2/tweets/:id/liking_users

twitter api 1.1 url count alternative

I've been using the old url api(v1) to get the count of a given url, lately I needed to get also the re-tweets and started searching about that.
this is the exact url I'm using right now:
http://urls.api.twitter.com/1/urls/count.json?url=http://google.com
As I viewed with some reading the v1 api is deprecated but at least it's still working.
I found some questions on the dev page of twitter:
https://dev.twitter.com/discussions/12643
those are a little old questions and have no specific solving to the problem. I mean, the most near solution was using the search api(search/tweets) which could be good but not a exactly replacement for the urls/count method.
Please note that Twitter's search service and, by extension, the
Search API is not meant to be an exhaustive source of Tweets. Not all
Tweets will be indexed or made available via the search interface.
also it has a limit for 100 results at maximum per 'page', even it throws the link to get the next set of objects, thats good but when the search reaches 1 million of results I'll need to get page over page to now how much tweets I got and having to do to much request to the api...
I sought some question over the dev page on twitter suggested using the stream api, I've tried using (statuses/filter) but that don't work very well given a URL as track param(which they said that is the keyword to track).
So, anyone who's been using the old urls/count has found a reliable alternative with the new apiv1.1, especiffically to get the tweets and re-tweets for a given url ?
The official suggestion by Twitter staff is that either the search/tweets endpoint (having just the last 7 days data) or the Streaming API be used (handling yourself the counters, making everything just too complicated for a d*mn counter).
As an extra warning, the old endpoint (http://urls.api.twitter.com/1/urls/count.json?url=YOUR_URL) will stop working on November 20th, and according to this blog post from Twitter there are no plans to replace it with anything in the short term and they are even removing the count from their own buttons.

How should I get all the tweets of an specific hashtag?

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.

Long URLs from Twitter feeds without making additional API calls/HTTP requests

Is there any built-in way to get the long, expanded URL from a twitter RSS feed? Right now the feed lists all the urls as http://t.co.... I'd like to do what the Twitter display does and display the long URLs; I'd also like to avoid having to do either an API call or HTTP request for each URL in the feed. Ideally, I'd also like to avoid using the Twitter API directly but if that's the only way, so be it.
Clarification
I'm not interested in doing a separate request for every single t.co link, or calling the Twitter API. I was hoping there was a single request I could make that would include the long URLs in the metadata (or even provide the tweet in full expanded form as it appears on Twitter). Turns out the way to do this is by requesting the JSON version from search.twitter.com rather than the RSS feed, and tacking on include_entities=True.
Rewrite, hopefully this makes it more clear
I'm using http://search.twitter.com/search.rss to get a feed of tweets matching a search term. The feed contains only the shortened t.co urls. Is there a way to modify my request so that the tweets contain the expanded URLs instead?
The goal is to do just one request rather than having to go through the tweets and parse each t.co url separately (especially since for a feed with several dozen t.co urls, that means several dozen separate requests). If necessary, I am willing to use the Twitter API directly to do the search instead of using RSS, but for my purposes using a feed is more ideal.
No, Twitter does not offer a urls entity in its RSS responses, nor does the include_entities option appear to work. You'll have to use a different response format e.g. JSON (with which you can use the include_entities option which includes an entities['urls'][n]['expanded_url'] object), or "unshorten" the URLs yourself after the fact.
There is a way to do this without using the Twitter API directly. You can use one of several resources,
http://expandurl.appspot.com/
API call prototype : http://expandurl.appspot.com/expand?url=
http://longurl.org
API call prototype : http://api.longurl.org/v2/expand?url=
http://unshort.me/
API call prototype: http://api.unshort.me/?r=http://
of course you can also use the Twitter API directly for this as Jordan mentioned by including &include_entities=1 or true as a parameter to some calls.
also try to CURL the URL and see what information you can gleam from that. I think this pretty much exhausts the options.

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