dominium/hybridauth

Open source social sign on PHP library.

dev-master / 3.0.x-dev 2016-02-09 08:29 UTC

This package is not auto-updated.

Last update: 2024-04-19 17:31:51 UTC


README

Build Status Scrutinizer Code Quality Latest Stable Version Total Downloads License Join the chat at https://gitter.im/hybridauth/hybridauth

IMPORTANT: This is a work in progress and subject to changes at any time.

Hybridauth enables developers to easily build social applications and tools to engage websites visitors and customers on a social level by implementing social sign-in, social sharing, users profiles, friends list, activities stream, status updates and more.

The main goal of Hybridauth is to act as an abstract API between your application and various social apis and identities providers such as Facebook, Twitter and Google.

You can find complete Hybridauth documentation at https://hybridauth.github.io

Usage

Hybridauth provides a number of basic examples.

...

New way of doing things :
    require 'vendor/autoload.php';

    $config = [
        'callback' => 'http://localhost/hybridauth/examples/twitter.php',

        'keys' => [ 'key'    => 'your-consumer-key', 'secret' => 'your-consumer-secret' ]
    ];

    $twitter = new Hybridauth\Provider\Twitter( $config );

    try {
        $twitter->authenticate();

        $userProfile = $twitter->getUserProfile();

        $accessToken = $twitter->getAccessToken();

        $apiResponse = $twitter->apiRequest( 'statuses/home_timeline.json' );
    }
    catch( Exception $e ){
        echo "Ooophs, we ran into an issue! " . $e->getMessage();
    }
Legacy way (Similar to Hybridauth 2.x)

Please refer to Upgrade guide to make the neccessary changes to your existing application in order to make it work with HybridAuth 3.x.

    require 'hybridauth_autoload.php';

    $config = array(
        'base_url'  => 'http://localhost/hybridauth/examples/callback.php',

        'providers' => array(
            'GitHub' => array(
                'enabled' => true,
                'keys'    => array ( 'id' => '', 'secret' => '' ),
            )
        )
    );

    $hybridauth = new Hybridauth( $config );

    try{
        $github = $hybridauth->authenticate( "GitHub" );

        $user_profile = $github->getUserProfile();

        echo "Hi there " . $user_profile->displayName;
    }
    catch( Exception $e ){
        echo "Ooophs, we ran into an issue! " . $e->getMessage();
    }

Requirements

  • PHP 5.4
  • PHP Session
  • PHP CURL

Dependencies

Hybridauth depends on few external libraries that come already included in HybridAuth:

Installation

We recommend that you always use the latest release available at https://github.com/hybridauth/hybridauth/releases, but we also support installation using Composer.

Note: Please, avoid using the master branch, as we usually keep it for development.

When using Composer, you have to add Hybridauth to your project dependencies:

"require": {
    "hybridauth/hybridauth": "3.0.*"
}

Install Composer and Dependencies:

$ curl -s http://getcomposer.org/installer | php
$ php composer.phar install

Get Involved

Hybridauth is a community driven project and accepts contributions of code and documentation from the community.

For more information, see https://hybridauth.github.io/getinvolved.html.

Questions, Help and Support?

For general questions (i.e, "how-to" questions), please consider using StackOverflow instead of the Github issues tracker. For convenience, we also have a [low-activity] mailing list at Google Groups and a Gitter channel if you want to get help directly from the community.

Project maintainers

Thanks

Big thanks to everyone who have contributed to Hybridauth by submitting patches, new ideas, code reviews and constructive discussions.

The list of the awesome people who have contributed to Hybridauth on Github can be found at https://github.com/hybridauth/hybridauth/graphs/contributors

License

Hybridauth PHP Library is released under the terms of MIT License.

For the full Copyright Notice and Disclaimer, see COPYING.md.