Skip to content

Latest commit

 

History

History
106 lines (76 loc) · 3.56 KB

README.md

File metadata and controls

106 lines (76 loc) · 3.56 KB

Twitter Bundle

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.

knpbundles.com

Requirements

Installation

Use Composer to install the bundle.

$ composer require endroid/twitter-bundle

Then enable the bundle via the kernel.

<?php
// app/AppKernel.php

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

Configuration

config.yml

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

Routing

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

EndroidTwitterBundle:
    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.

Usage

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

<?php

$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());

Versioning

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.

License

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.