Nowadays it’s very common to find shorted URLs everywhere. I had to deal with this stuff when i had to work with Twitter and its tweets data and i think it might be useful for other people too.

This is what i did:

 * Gets the real URL from a shorted one.
 * In case the URL isn't shorted, it returns the same one.
 * @access public
 * @param string $short URL
 * @return string real URL.
public function getReal($short){
    $headers = get_headers($short, 1);
    $loc = $headers['Location'];

        // get the highest numeric index
        // in case the URL is shorted more than once
        $key = max(array_keys( $loc));

        return $loc[$key];
    }else if(!empty($loc)){
        return $loc;
        return $short;

You can have a look at get_headers function at the PHP documentation site