phenomblue
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
b-summers, have you tried manually navigating to https://api.twitter.com/1/statuses/user_timeline/phenomblue.rss (replacing phenomblue with your twitter username) to see if the API call works?
Thanks leonelcamara-iam, that was very helpful! You forgot to update $message[‘pubdate’] to $message->get_date() though so it was throwing an error if the $update flag was enabled. Here’s a version with that fix:
function twitter_messages($username = '', $num = 1, $list = false, $update = true, $linked = '#', $hyperlinks = true, $twitter_users = true, $encode_utf8 = false) { global $twitter_options; include_once(ABSPATH . WPINC . '/rss.php'); $rss= fetch_feed('https://api.twitter.com/1/statuses/user_timeline/'.$username.'.rss'); if ($list) echo '<ul class="twitter">'; if ($username == '') { if ($list) echo '<li>'; echo 'RSS not configured'; if ($list) echo '</li>'; } else { if ( is_wp_error($rss) ) { if ($list) echo '<li>'; echo 'No public Twitter messages'; if ($list) echo '</li>'; } else { $messages = $rss->get_items(0, $num); foreach ($messages as $message ) { $msg = " ".substr(strstr($message->get_description(),': '), 2, strlen($message->get_description()))." "; if($encode_utf8) { $msg = utf8_encode($msg); } $link = $message->get_permalink(); if ($list) echo '<li class="twitter-item">'; elseif ($num != 1) echo '<p class="twitter-message">'; if ($hyperlinks) { $msg = hyperlinks($msg); } if ($twitter_users) { $msg = twitter_users($msg); } if ($linked != '' || $linked != false) { if($linked == 'all') { $msg = '<a href="'.$link.'" class="twitter-link">'.$msg.'</a>'; // Puts a link to the status of each tweet } else { $msg = $msg . '<a href="'.$link.'" class="twitter-link">'.$linked.'</a>'; // Puts a link to the status of each tweet } } echo $msg; if($update) { $time = strtotime($message->get_date()); if ( ( abs( time() - $time) ) < 86400 ) { $h_time = sprintf( __('%s ago'), human_time_diff( $time ) ); } else { $h_time = date(__('Y/m/d'), $time); } echo sprintf( __('%s', 'twitter-for-wordpress'),' <br/><span class="twitter-timestamp"><abbr title="' . date(__('Y/m/d H:i:s'), $time) . '">' . $h_time . '</abbr></span>' ); } if ($list) echo '</li>'; elseif ($num != 1) echo '</p>'; } /* end foreach*/ } /* close else */ } if ($list) echo '</ul>'; }
Viewing 2 replies - 1 through 2 (of 2 total)