Skip to content

Instantly share code, notes, and snippets.

@deletosh
Created February 29, 2012 20:18
Show Gist options
  • Save deletosh/1944107 to your computer and use it in GitHub Desktop.
Save deletosh/1944107 to your computer and use it in GitHub Desktop.
for iMarcist 1
private function _twitter($tweet_count, $username) {
if (empty($username)) {
return false;
}
// $this->_fetch_tweet();
$tweets = get_transient('recent_tweets_widget');
if (!$tweets) {
$this->_fetch_tweets($tweet_count, $username);
}
return $tweets;
}
private function _fetch_tweets($tweet_count, $username) {
// print_r($username);
$tweets = wp_remote_get("https://twitter.com/statuses/user_timeline/$username.json", array('sslverify' => false));
$tweets = json_decode($tweets['body']);
// print_r($tweets);
if (isset($tweets->error)) {
return false;
}
$data = new stdClass();
$data->username = $username;
$data->tweet_count = $tweet_count;
$data->tweets = array();
// print_r($data);
foreach ($tweets as $tweet) {
if ($tweet_count-- == 0) {
break;
}
echo $this->filter_tweet($tweet->text);
// echo $tweet->description;
}
set_transient('recent_tweets_widgets', $data, 60 * 5);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment