Skip to content

Instantly share code, notes, and snippets.

@deanc
Created March 24, 2014 12:52
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 deanc/9739481 to your computer and use it in GitHub Desktop.
Save deanc/9739481 to your computer and use it in GitHub Desktop.
Pull in 5 latest tweets from twitter
$twitter_client = new \Guzzle\Http\Client('https://api.twitter.com/{version}', array(
'version' => '1.1'
));
$twitter_client->addSubscriber(new \Guzzle\Plugin\Oauth\OauthPlugin(array(
'consumer_key' => TWITTER_CONSUMER_KEY,
'consumer_secret' => TWITTER_CONSUMER_SECRET,
'token' => TWITTER_ACCESS_TOKEN,
'token_secret' => TWITTER_ACCESS_TOKEN_SECRET
)));
$request = $twitter_client->get('statuses/user_timeline.json');
$request->getQuery()->set('count', 5);
$request->getQuery()->set('screen_name', TWITTER_USERNAME);
$response = $request->send();
header('Content-Type: application/json; charset=utf-8');
echo $response->getBody();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment