1.2.0 2016-06-23 23:27 UTC


By endroid

Latest Stable Version Build Status Total Downloads Monthly Downloads License

This bundle enables you to use Endroid Twitter as a service in your Symfony project. It also provides an API controller that takes a local API request, adds an OAuth signature to it and returns the corresponding Twitter API response. This enables you to expose the Twitter API on your own domain without having to bother about OAuth signing your requests.

For more information see the endroid/Twitter repository and the Twitter API.




Use Composer to install the bundle.

$ composer require endroid/twitter-bundle

Then enable the bundle via the kernel.

// app/AppKernel.php

public function registerBundles()
    $bundles = array(
        // ...
        new Endroid\Bundle\TwitterBundle\EndroidTwitterBundle(),



    consumer_key: "..."
    consumer_secret: "..."
    access_token: "..."
    access_token_secret: "..."


If you don't want to expose the Twitter API via your application, you can skip this section.

    resource:   "@EndroidTwitterBundle/Controller/"
    type:       annotation
    prefix:     /twitterapi

This exposes the Twitter API via /twitterapi. This means that instead of sending a signed request to https://dev.twitter.com/docs/api/1.1/* you can now send an unsigned request to /twitterapi/*. Make sure you secure this area if you don't want others to be able to post on your behalf.


After installation and configuration, the service can be directly referenced from within your controllers.


$twitter = $this->get('endroid.twitter');

// Retrieve the user's timeline
$tweets = $twitter->getTimeline(array(
    'count' => 5

// Or retrieve the timeline using the generic query method
$response = $twitter->query('statuses/user_timeline', 'GET', 'json');
$tweets = json_decode($response->getContent());


Version numbers follow the MAJOR.MINOR.PATCH scheme. Backwards compatibility breaking changes will be kept to a minimum but be aware that these can occur. Lock your dependencies for production and test your code when upgrading.


This bundle is under the MIT license. For the full copyright and license information please view the LICENSE file that was distributed with this source code.