A quick Internet search for Symfony Twitter API service will reveal Gonzalo Ayuso’s two year old article How to configure Symfony’s Service Container to use Twitter API (DZone mirror) for Guzzle 3.0. Unfortunately these config files are now out-of-date with a PSR-7 rewrite of Guzzle‘s HTTP Client in version 6.0 published one month ago.
These configurations only cover OAuth 1.0. The goal is to setup the service by Symfony’s dependency injection without any PHP required. Then you can invoke a Twitter REST API call within a controller action (or another service):
$client = $this->get('guzzle.twitter.client');
$query = 'search/tweets.json?q=' . urlencode($q);
$response = $client->get($query);
$statuses = $response->json();
So here are the packages and YAML changes for each major revision.
Read the rest of this entry »