Issues with Twitter feed creating links automatically (pic.twitter.com)


#1

I am using a Twitter feed on a website and everything is working except for the automatic creation of links for only some instances. It seems that links are not automatically being created for pic.twitter.com links (is it because the pic.twitter.com links are https?). All other links (including #'s and @'s) are working as they should. Not sure if this is the fault of my PHP or how the links are being added to Twitter feed. Any help would be appreciated.

Twitter feed: https://twitter.com/PRP_Inc

Code for creating links:

  if(is_array($tweet['entities']['user_mentions'])){
            foreach($tweet['entities']['user_mentions'] as $key => $user_mention){
                $the_tweet = preg_replace(
                    '/@'.$user_mention['screen_name'].'/i',
                    '<a href="http://www.twitter.com/'.$user_mention['screen_name'].'" target="_blank">@'.$user_mention['screen_name'].'</a>',
                    $the_tweet);
            }
        }

  if(is_array($tweet['entities']['hashtags'])){
            foreach($tweet['entities']['hashtags'] as $key => $hashtag){
                $the_tweet = preg_replace(
                    '/#'.$hashtag['text'].'/i',
                    '<a href="https://twitter.com/search?q=%23'.$hashtag['text'].'&src=hash" target="_blank">#'.$hashtag['text'].'</a>',
                    $the_tweet);
            }
        }

if(is_array($tweet['entities']['urls'])){
           foreach($tweet['entities']['urls'] as $key => $link){
                $the_tweet = preg_replace(
                '`'.$link['url'].'`',
                 '<a href="'.$link['url'].'" target="_blank">'.$link['url'].'</a>',
                $the_tweet);
       }
}

Regular links are being converted to “http://t.co” and links are being created, https://pic.twitter.com links are being converted to “http://t.co” but aren’t actually clickable.