-
-
Save midoooo/e2534bcdf5be02728914 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @link http://jonathonhill.net/2012-05-18/unshorten-urls-with-php-and-curl/ | |
*/ | |
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); | |
$url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); | |
curl_close($ch); | |
return $url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment