Git Product home page Git Product logo

twitteroauth's Introduction

TwitterOAuth

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:

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

Dependency

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.

Usage

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');

$tw->setAccessToken(...);

// 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);

Resources

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

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

twitteroauth's People

Contributors

svenalhamad avatar

Stargazers

Nico Müller avatar

Watchers

James Cloos avatar Ben Read avatar Leonardo Giacone avatar  avatar Ewan avatar Pedro avatar Bruno Zorić avatar Ashutosh avatar  avatar  avatar

Forkers

isabella232

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.