Skip to content
Gabriele Romanato edited this page Jun 21, 2013 · 3 revisions

Setup

1. Go to dev.twitter.com and create a new app (read-only)
2. Once created your app, get the consumer key, consumer secret, access token and access token secret
3. Insert your 4 values into the twitterfeed/TwitterFeed.php class file:

class TwitterFeed {

	public $user;

	public $tweetsNumber;

	private $consumerKey = 'your value';

	private $consumerSecret = 'your value';

	private $accessToken = 'your value';

	private $accessTokenSecret = 'your value';

	private $connection;

        // continues

}

4. Open the twitterfeed.php file and set your Twitter username and the number of tweets you want to retrieve:

require_once('twitterfeed/TwitterFeed.php');
 
header('Content-Type: application/json');

$twitterFeed = new TwitterFeed('gabromanato', 1);

$twitterFeed->getTweets();

5. Now in the jQuery plugin use the url options so that it points to the twitterfeed.php file:

$('#tweets').twitterFeed({

   url: 'http://' + location.host + '/inc/twitter/twitterfeed.php'

 });

URLs can be either absolute or relative. Just make sure that they’re correct.

Options

We’ve already seen the url option. Another option is cache (boolean). If set to true, your tweets will be cached for 1 hour. By doing so, no further AJAX call will be performed:

$('#tweets').twitterFeed({

  url: 'http://' + location.host + '/inc/twitter/twitterfeed.php',

  cache: true

});
Clone this wiki locally