PHP Twitter OAuth
Library for accessing Twitter API using Twitter OAuth.


This component provides is a wrapper for Twitter OAuth server.

Install the component

The best way to install the component is using Composer.

composer require webiny/twitter-oauth

For additional versions of the package, visit the Packagist page.

Configuring the component

To use the component, you first need to configure it. The configuration is done by defining the following params:

  • ClientId - Twitter client id
  • ClientSecret - Twitter client secret
  • RedirectUri - location where the user will be redirected by the OAuth server, once he is authorized

Example configuration:

            ClientOd: AJmIXgXfaasdasaULBmnygIiGA
            ClientSecret: JE5dpb0a891ciisasdMOu7ELF9SI0TazR3hDAirft0Y
            RedirectUri: /security/login-tw/
        Bridge: \Webiny\Component\TwitterOAuth\Bridge\TwitterOAuth\TwitterOAuth


The library requires abraham/twitteroauth TwitterOAuth component. The will be installed automatically if you install TwitterOAuth Webiny component using composer, however, you will need to include this file somewhere in your application before you can use the component /path/to/abraham/twitteroauth/twitteroauth.php.


Once you have configured the component, its usage is fairly simple if you have an access token. If you don't have an access token, the best way to get one, is to authenticate the user using the Security component with TwitterOAuth as auth provider.

$tw = TwitterOAuthLoader::getInstance('MyTwitterApp');


// get user details for current access token
$user = $tw->getUserDetails(); // returns TwitterOAuthUser object

// perform any other API operation
$tw->get($url, $params);
$tw->post($url, $params);
$tw->delete($url, $params);


To run unit tests, you need to use the following command:

$ cd path/to/Webiny/Component/TwitterOAuth/
$ composer.phar install
$ phpunit

To learn what you can do with Webiny Framework, checkout Webiny Platform - open-source content management system.

Explore Webiny Framework components:

  • Amazon currently supports implementation of Amazon S3
  • Annotations component for parsing annotations from a class, method or a property
  • Cache provides several caching libraries like Apc, Couchbase, Memcache and Redis
  • ClassLoader a PSR-0, PSR-4 and PEAR class loader
  • Config a very handy library for parsing YAML, INI, JSON and PHP configuration files
  • Crypt library for encoding, decoding and validating hashes
  • Entity an ODM layer (currently only supports MongoDB)
  • EventManager want to do event-based development, this is a library for you
  • Http library for parsing HTTP requests and creating HTTP responses
  • Image library for image manipulation
  • Logger PSR-3 log components for logging code execution in runtime
  • Mailer component for sending emails
  • Mongo MongoDB class wrapper
  • OAuth2 library for working with OAuth2, currently supports Facebook, LinkedIn and Google+
  • REST fully featured REST library with caching, security and rate control
  • Router handles defining, parsing, creating and matching url routes
  • Security provides authorization and authentication layer
  • ServiceManager want to write truly service based, loosely-coupled code, this library provides that
  • StdLib this component provides object wrappers for Arrays, Strings, Urls and DateTime data types
  • Storage storage abstraction layer that simplifies the way you work with files and directories
  • TemplateEngine provides a layer for rendering view templates and defining template plugins and manipulators
  • TwitterOAuth library for working with Twitter API using Twitter OAuth


Lastest from our blog:

The Power of the Community

In the focus of recent feedback that I got, I think there is a need for me to justify some of the decisions we made while developing Webiny Framework.

Share & subscribe: