Skip to content

Instantly share code, notes, and snippets.

@tom4897
Last active December 21, 2015 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tom4897/6279185 to your computer and use it in GitHub Desktop.
Save tom4897/6279185 to your computer and use it in GitHub Desktop.
<?php
/* --------------------- */
require "class/twitteroauth.php";
$twitter_api = new TwitterOAuth (consumer_key, consumer_secret, oauth_token, oauth_token_secret);
$tweets = $twitter_api -> get ('statuses/user_timeline', array('count' => 5));
foreach ($tweets as $key => $tweets) {
echo "&bull; " . $tweets->text . "<br/>";
}
?>
OR
<?php
/* --------------------- */
// Parameters
$consumer_key = "";
$consumer_secret = "";
$oauth_token = "";
$oauth_token_secret = "";
$tweets_parameters = array('count' => 5);
// call class
require "class/twitteroauth.php";
$twitter_api = new TwitterOAuth ($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
// Get tweets
$tweets = $twitter_api -> get ('statuses/user_timeline', $tweets_parameters);
// Display Tweets
echo '<ul>';
foreach ($tweets as $key => $tweet) {
$user = $tweet->user;
echo "<li><a href='http://twitter.com/{$tweet->id_str}'>Tweet</a> &bull; {$tweet->text}<br/> <i>{$tweet->created_at}</i><br/></li>";
}
echo '</ul>';
// Destroy unnecessary object & variable
unset($twitter_api, $tweets);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment