Created
June 23, 2015 12:02
-
-
Save ericabouaf/8e8b597e64f9a5d2acf4 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
function resolve_tinyurl($tinyurl) { | |
$ch = curl_init($tinyurl); | |
curl_setopt($ch,CURLOPT_HEADER,true); | |
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); | |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,false); | |
$data = curl_exec($ch); | |
preg_match('#Location: ([^\n\r]*)#i', $data, $matches); | |
return $matches[1]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment