Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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