Created
March 24, 2014 12:52
-
-
Save deanc/9739481 to your computer and use it in GitHub Desktop.
Pull in 5 latest tweets from twitter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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