Skip to content

Instantly share code, notes, and snippets.

@ericabouaf
Created June 23, 2015 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericabouaf/8e8b597e64f9a5d2acf4 to your computer and use it in GitHub Desktop.
Save ericabouaf/8e8b597e64f9a5d2acf4 to your computer and use it in GitHub Desktop.
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