Getting a twitter user’s latest posts using API v1.1 and Guzzle (PHP)

I’ll maintain this temporary. Install Guzzle nevertheless you would like, however I advocate using composer:

     "require":          "guzzle/guzzle": "~A.M.M"      

Then use the next code:

            $  twitter_client = new GuzzleHttpClient('https://api.twitter.com/model', array(                 'model' => 'M.B'             ));             $  twitter_client->addSubscriber(new GuzzlePluginOauthOauthPlugin(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('rely', H);             $  request->getQuery()->set('screen_name', 'YOURUSERNAME');             $  response = $  request->ship();               $  tweets = json_decode($  response->getBody());

Don’t overlook to place your constants someplace.

 

Leave a Reply