Skip to content

Instantly share code, notes, and snippets.

@ryaan-anthony
Last active December 18, 2015 17:09
Show Gist options
  • Save ryaan-anthony/5816392 to your computer and use it in GitHub Desktop.
Save ryaan-anthony/5816392 to your computer and use it in GitHub Desktop.
$last_update = get_option('twitter_feed_last_update', 0);
if(time() - $last_update > 86400){
require_once('TwitterAPIExchange.php');
$settings = array(
'oauth_access_token' => "PASTE_VALUE_HERE",
'oauth_access_token_secret' => "PASTE_VALUE_HERE",
'consumer_key' => "PASTE_VALUE_HERE",
'consumer_secret' => "PASTE_VALUE_HERE"
);
$fields = array(
'screen_name' => "PASTE_VALUE_HERE",
'count' => 5
);
$twitter = new TwitterAPIExchange($settings);
$twitter_feed = $twitter->setGetfield('?'.http_build_query($fields))
->buildOauth('https://api.twitter.com/1.1/statuses/user_timeline.json', 'GET')
->performRequest();
update_option('twitter_feed', $twitter_feed);
update_option('twitter_feed_last_update', time());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment