Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find where a t.co link goes to

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.

like image 384
hookedonwinter Avatar asked Jun 28 '11 01:06

hookedonwinter


People also ask

How do I get the T Co link?

You use t.co whenever you post Twitter links. Simply copy and paste a URL into a tweet, reply, or DM, and t.co will automatically convert it into a link of 23 characters or less. This helps keep your tweets under the character limit so you can add more to your post.

How do I find my Tinyurl?

Type the shortened URL in the address bar of your web browser and add the characters described below to see a preview of the full URL: tinyurl.com. Between the "http://" and the "tinyurl," type preview. bit.ly.

Are Cutt ly links Safe?

Cuttly, thanks to a responsible approach to the safety of short links, uses many systems to assess and suspect links and block links categorized as spam, phishing, etc. Cuttly has its own security system: Cuttly Safe Redirecting, which actively cares about security. Cuttly is GDPR compliant.

How do you get a link to a Twitter video?

Copy the Twitter video linkIf you're on a browser, you can copy the URL right out of the browser's address bar. You can also click the share button on the bottom right corner of the tweet, and select "Copy link to Tweet." If you're on mobile, click the share button on the bottom right corner of the tweet.


1 Answers

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:

function unshorten_url($url) {   $ch = curl_init($url);   curl_setopt_array($ch, array(     CURLOPT_FOLLOWLOCATION => TRUE,  // the magic sauce     CURLOPT_RETURNTRANSFER => TRUE,     CURLOPT_SSL_VERIFYHOST => FALSE, // suppress certain SSL errors     CURLOPT_SSL_VERIFYPEER => FALSE,    ));   curl_exec($ch);    return curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); } 

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/

like image 191
Jonathon Hill Avatar answered Oct 08 '22 23:10

Jonathon Hill