Skip to content

Instantly share code, notes, and snippets.

@tom4897
Last active Dec 21, 2015
Embed
What would you like to do?
<?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