Given a t.co link, how can I find see where the link resolves? For example, if I have t.co/foo, I want a function or process that returns domain.com/bar.
相关问题
- Rails how to handle error and exceptions in model
- CORS issue with Twitter api calls in Webpack dev s
- Twitter sign in crashes with TWTRInvalidInitializa
- Accessing Twitter through Javascript
- Swift 3: How to reverse a transparent Navigation B
相关文章
- is there a callback option with twitter's “fol
- Twitter name length in DB
- Twitter oauth refresh token
- Login with Twitter on iOS
- linqtotwitter - grab the saved credentials
- Getting the location using Tweepy
- Making any tweet favourite through iOS 5 twitter A
- How to obscure the id in a url (ruby on rails) [du
I would stay away from external APIs over which you have no control. That will simply introduce a dependency into your application that is a potential point of failure, and could cost you money to use.
CURL can do this quite nicely. Here's how I did it in PHP:
I'm sure this could be adapted to other languages or even scripted with the
curl
command on UNIXy systems.http://jonathonhill.net/2012-05-18/unshorten-urls-with-php-and-curl/
If you want to do it from the command line, curl's verbose option comes to the rescue:
gives you the HTTP reply. For t.co it seems to give you an HTTP/301 reply (permanently moved). Then, there's a Location field, which points to the URL behind the shortened one.
Twitter expands the URL. Assume you have a single tweet using twitter API encoded as json file.
You can observe that there is a value called 'urls' tweet['entities']['urls'] # gives values mapped to key urls