Component for Yii Framework based application which provides simple configuration interface for HybridAuth library.
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' => ''),
),
),
),
),
);
Example:
$twitter = Yii::app()->auth->authenticate('Twitter');
$userProfile = $twitter->getUserProfile();
echo sprintf('Hi there, %s!', $userProfile->displayName);
$twitter->setUserStatus('Hello, World!');
$userContacts = $twitter->getUserContacts();