Twitter Feed not pulling in on Site // Error

JoseCowles40

New Member
I'm wondering why, within the sidebar of my wordpress theme, This code is not pulling in my latest tweets?\[code\]<?php/* PHP Twitter Feed Importer @mradamdavies www.elevatelocal.co.uk==-----------------------------*/class pull_tweets { // Create a basic classvar $twitter_handle; // Twitter usernamevar $tweet_limit; // Max tweets to returnvar $tweet_links; // Show @profile linksvar $tweet_tags; // Show #tag linksvar $tweet_avatar; // Show twitter avatarvar $tweet_profile; // Show twitter profile linkvar $hard_max; // Real max tweets (Used to filter out @replies)var $i; // Tweet counterfunction show_tweet_links($tweet_links_output, $tweet_links) { // Find and replace @replies with links if($tweet_links == true) { $find = '/\@([a-zA-Z]+)/'; $replace = '<a class="hash_link" href="http://twitter.com/'.strtolower('\1').'" rel="nofollow">@\1</a>'; $tweet_links_text = preg_replace($find,$replace,$tweet_links_output); return $tweet_links_text; } else { return $tweet_links_output; }}function show_hash_tags($tweet_hashtags_output, $tweet_tags) { // Find and replace #tags with links if($tweet_tags == true) { $find_hash_tag = '/\#([a-zA-Z]+)/'; $replace_hash_tag = '<a class="hash_link" href="http://twitter.com/search?q=%23'.strtolower('\1').'" rel="nofollow">#\1</a>'; return preg_replace($find_hash_tag,$replace_hash_tag,$tweet_hashtags_output); } else { return $tweet_hashtags_output; }}function show_twitter_avatar($tweet_avatar_output, $tweet_avatar) { // Show avatar if($tweet_avatar == true) { return '<img src="'.$tweet_avatar_output.'" alt="" />'; } else { return false; }}function show_twitter_profile_link($tweet_profile_output, $tweet_profile) { // Insert profile link if($tweet_profile == true) { return '<a class="profile_link" href="http://twitter.com/'.$tweet_profile_output.'">@'.$tweet_profile_output.'</a>'; } else { return false; }}// Create a basic function to pull latest tweetsfunction tweets($twitter_handle, $tweet_limit, $tweet_links, $tweet_tags, $tweet_avatar, $tweet_profile) { /* Store Tweets in a JSON object */ $tweet_feed = json_decode(file_get_contents('http://api.twitter.com/1/statuses/user_timeline.json?screen_name='. $twitter_handle.'&exclude_replies=false&count='.$hard_max)); $i = 0; // Start the tweet limit counter foreach ($tweet_feed as $tweet) { // Loop through the tweets if ($tweet->in_reply_to_user_id == '' && $i != $tweet_limit) { // Don't show direct @replies ++$i; // Increase tweet counter // Check true/false flags and return output accoringly $tweet_text = $tweet->text; $tweet_text = pull_tweets::show_tweet_links($tweet_text,$tweet_links); // Show @reply links? $tweet_text = pull_tweets::show_hash_tags($tweet_text,$tweet_tags); // Show #tag links? $twitter_avatar =pull_tweets::show_twitter_avatar($tweet->user->profile_image_url,$tweet_avatar); // Show avatar? $twitter_profile = pull_tweets::show_twitter_profile_link($twitter_handle,$tweet_profile); // Show main profile link? // Echo our tweet contents echo ' <div class="tweet_bg">',$twitter_avatar,' <p>'.$tweet_text.'<br />'.$twitter_profile.'</p> </div>'; } } // end of foreach } // end of tweets function} // end of pull_tweets class?><script language="javascript">$my_tweets = new pull_tweets();echo $my_tweets->tweets('mradamdavies', 5, true, true, true, true);</script>\[/code\]Referred by this tutorial:*http://www.elevatelocal.co.uk/blog/php-twitter-feed-importer-05094504*I want to do this with PHP or minimal JavaScript. Currently Twitter Widgets are not working on my site for some reason.
 
Back
Top