sobit/hybridauth-component

Component for Yii Framework based application which provides simple configuration interface for HybridAuth library.

dev-master 2013-11-17 16:51 UTC

This package is not auto-updated.

Last update: 2024-04-23 03:57:09 UTC


README

Component for Yii Framework based application which provides simple configuration interface for HybridAuth library.

Installation

Add dependency to your composer.json file:

{
    "require": {
        "sobit/hybridauth-component": "dev-master"
    }
}

Update your protected/config/main.php file:

<?php

Yii::setPathOfAlias('vendor', dirname(__FILE__) . '/../../vendor');

return array(
    'components' => array(
        'auth' => array(
            'class'     => 'vendor.sobit.hybridauth-component.HybridAuthComponent',
            'action'    => 'controller/action',
            'debugMode' => false,
            'providers' => array(
                'Google' => array(
                    'enabled' => true,
                    'keys'    => array('id' => '', 'secret' => ''),
                ),
                'Facebook' => array(
                    'enabled' => true,
                    'keys'    => array('id' => '', 'secret' => ''),
                    'scope'   => 'email, user_about_me, user_birthday, user_hometown',
                ),
                'Twitter' => array(
                    'enabled' => true,
                    'keys'    => array('id' => '', 'secret' => ''),
                ),
            ),
        ),
    ),
);

Usage

Example:

$twitter = Yii::app()->auth->authenticate('Twitter');
$userProfile = $twitter->getUserProfile();
echo sprintf('Hi there, %s!', $userProfile->displayName);
$twitter->setUserStatus('Hello, World!');
$userContacts = $twitter->getUserContacts();