Twitter OAuth API for PHP 5.3+

Overview

README

Build Status

The Wid'op OAuth library is a modern PHP 5.3+ API allowing you to easily obtain a Twitter access token. For now, it supports OAuth Web & Application tokens (not xOAuth).

Here a sample for the Web workflow:

use Widop\HttpAdapter\CurlHttpAdapter;
use Widop\Twitter\OAuth;

// First, instantiate your OAuth client.
$oauth = new OAuth\OAuth(
    new CurlHttpAdapter(),
    new OAuth\OAuthConsumer('consumer_key', 'consumer_secret'),
    new OAuth\Signature\OAuthHmacSha1Signature()
);

// Second, get/cache a "request token" somewhere (here in session)
if (!isset($_SESSION['my_request_session'])) {
    $requestToken = $oauth->getRequestToken('http://my-app.com/twitter-callback.php');
    $_SESSION['my_request_session'] = serialize($requestToken);
} else {
    $requestToken = unserialize($_SESSION['my_request_token']);
}

// Third, redirect the user on twitter for getting permissions
echo '<a href="'.$oauth->getAuthorizeUrl($requestToken).'">Authorize the application</a>';

// Then, get an "access token"
if (isset($_REQUEST['oauth_verifier'])) {
    $accessToken = $oauth->getAccessToken($requestToken, $_REQUEST['oauth_verifier']);

    // Save the access token somewhere for further purpose!
}

Documentation

  1. Installation
  2. OAuth

Testing

The library is fully unit tested by PHPUnit with a code coverage close to 100%. To execute the test suite, check the travis configuration.

Contribute

We love contributors! The library is open source, if you'd like to contribute, feel free to propose a PR!

License

The Wid'op OAuth library is under the MIT license. For the full copyright and license information, please read the LICENSE file that was distributed with this source code.

You might also like...
Open source social sign on PHP Library. HybridAuth goal is to act as an abstract api between your application and various social apis and identities providers such as Facebook, Twitter and Google.

Hybridauth 3.7.1 Hybridauth enables developers to easily build social applications and tools to engage websites visitors and customers on a social lev

Easy integration with OAuth 2.0 service providers.

OAuth 2.0 Client This package provides a base for integrating with OAuth 2.0 service providers. The OAuth 2.0 login flow, seen commonly around the web

OAuth 1 Client

OAuth 1.0 Client OAuth 1 Client is an OAuth RFC 5849 standards-compliant library for authenticating against OAuth 1 servers. It has built in support f

OAuth client integration for Symfony. Supports both OAuth1.0a and OAuth2.

HWIOAuthBundle The HWIOAuthBundle adds support for authenticating users via OAuth1.0a or OAuth2 in Symfony. Note: this bundle adds easy way to impleme

An OAuth 2.0 bridge for Laravel and Lumen [DEPRECATED FOR LARAVEL 5.3+]
An OAuth 2.0 bridge for Laravel and Lumen [DEPRECATED FOR LARAVEL 5.3+]

OAuth 2.0 Server for Laravel (deprecated for Laravel 5.3+) Note: This package is no longer maintaned for Laravel 5.3+ since Laravel now features the P

This module is intended to provide oauth authentication to freescout.

OAuth FreeScout This module is intended to provide oauth authentication to freescout. Module was tested on keycloak oauth provider with confidential o

A Laravel 5 package for OAuth Social Login/Register implementation using Laravel socialite and (optionally) AdminLTE Laravel package

laravel-social A Laravel 5 package for OAuth Social Login/Register implementation using Laravel socialite and (optionally) AdminLTE Laravel package. I

OAuth Service Provider for Laravel 4

OAuth wrapper for Laravel 4 oauth-4-laravel is a simple laravel 4 service provider (wrapper) for Lusitanian/PHPoAuthLib which provides oAuth support i

OAuth Service Provider for Laravel 5

OAuth wrapper for Laravel 5 oauth-5-laravel is a simple laravel 5 service provider (wrapper) for Lusitanian/PHPoAuthLib which provides oAuth support i

Comments
  • Introduce OAuth response and exception

    Introduce OAuth response and exception

    This PR is the second step in order to fix widop/twitter-rest#33. Now, the sendRequest method returns a OAuthResponse which wraps the original http response and some convenient method in order to easily access usefull informations.

    Additionally, it introduces the OAuthException which wraps an OAuthResponse allowing to have a more complete access to the informations related to the error.

    opened by egeloen 0
  • Create new release

    Create new release

    Hi,

    would you be so kind to create a release on this page?

    • https://github.com/widop/twitter-oauth/releases

    For example with version "1.0.0". Just 2 clicks.

    Now Packagist / Composer started to throw error messages for packages, which lack a release, and use "dev-master" instead.

    opened by bolner 0
Owner
Wid'op
Wid'op
The first PHP Library to support OAuth for Twitter's REST API.

THIS IS AN MODIFIED VERSION OF ABRAHAMS TWITTER OAUTH CLASS The directories are structured and the class uses PHP5.3 namespaces. Api.php has a new

Ruud Kamphuis 51 Feb 11, 2021
The most popular PHP library for use with the Twitter OAuth REST API.

TwitterOAuth The most popular PHP library for Twitter's OAuth REST API. See documentation at https://twitteroauth.com. PHP versions listed as "active

Abraham Williams 4.2k Dec 23, 2022
Twitter OAuth API for PHP 5.3+

README The Wid'op OAuth library is a modern PHP 5.3+ API allowing you to easily obtain a Twitter access token. For now, it supports OAuth Web & Applic

Wid'op 8 Dec 11, 2020
Laravel wrapper around OAuth 1 & OAuth 2 libraries.

Introduction Laravel Socialite provides an expressive, fluent interface to OAuth authentication with Facebook, Twitter, Google, LinkedIn, GitHub, GitL

The Laravel Framework 5.2k Dec 27, 2022
EAuth extension allows to authenticate users by the OpenID, OAuth 1.0 and OAuth 2.0 providers

EAuth extension allows to authenticate users with accounts on other websites. Supported protocols: OpenID, OAuth 1.0 and OAuth 2.0.

Maxim Zemskov 330 Jun 3, 2022
A simple twitter SDK to interact with Twitter api (1.1)

Twitter SDK Installation composer require lyrixx/twitter-sdk Usage Create a twitter application then <?php require __DIR__.'/vendor/autoload.php';

Grégoire Pineau 37 Aug 28, 2020
OAuth server implementation for WP API

WP REST API - OAuth 1.0a Server Connect applications to your WordPress site without ever giving away your password. This plugin uses the OAuth 1.0a pr

WordPress REST API Team 314 Dec 10, 2022
A spec compliant, secure by default PHP OAuth 2.0 Server

PHP OAuth 2.0 Server league/oauth2-server is a standards compliant implementation of an OAuth 2.0 authorization server written in PHP which makes work

The League of Extraordinary Packages 6.2k Jan 4, 2023
PHP 5.3+ oAuth 1/2 Client Library

PHPoAuthLib NOTE: I'm looking for someone who could help to maintain this package alongside me, just because I don't have a ton of time to devote to i

David Desberg 1.1k Dec 27, 2022
Kaiju is an open source verification bot based on Discord's OAuth written in C# and PHP, with the functionality of being able to integrate the user to a new server in case yours is suspended.

What is Kaiju? Kaiju is an open source verification bot for Discord servers, based on OAuth and with permission for the server owner, to be able to mi

in the space 10 Nov 20, 2022