1. Go to this page and download the library: Download sleepwalker/hoauth library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
class SiteController extends Controller
{
/**
* Declares class-based actions.
*/
public function actions()
{
return array(
'oauth' => array(
// the list of additional properties of this action is below
'class'=>'ext.hoauth.HOAuthAction',
// Yii alias for your user's model, or simply class name, when it already on yii's import path
// default value of this property is: User
'model' => 'User',
// map model attributes to attributes of user's social profile
// model attribute => profile attribute
// the list of avaible attributes is below
'attributes' => array(
'email' => 'email',
'fname' => 'firstName',
'lname' => 'lastName',
'gender' => 'genderShort',
'birthday' => 'birthDate',
// you can also specify additional values,
// that will be applied to your model (eg. account activation status)
'acc_status' => 1,
),
),
// this is an admin action that will help you to configure HybridAuth
// (you must delete this action, when you'll be ready with configuration, or
// specify rules for admin role. User shouldn't have access to this action!)
'oauthadmin' => array(
'class'=>'ext.hoauth.HOAuthAdminAction',
),
);
}
}
/**
* Returns User model by its email
*
* @param string $email
* @access public
* @return User
*/
public function findByEmail($email)
{
return self::model()->findByAttributes(array('email' => $email));
}
$this->widget('ext.hoauth.widgets.HOAuth');
...
"Facebook" => array (
"enabled" => true,
"keys" => array ( "id" => "PUT_YOURS_HERE", "secret" => "PUT_YOURS_HERE" ),
"scope" => "email, user_about_me, user_birthday, user_hometown", // you can change the data, that will be asked from user
"display" => "popup" // <- this one
)
...
$userOAuths = UserOAuth::model()->findUser(5); // find all authorizations from user with id=5
foreach($userOAuths as $userOAuth)
{
$profile = $userOAuth->profile;
echo "Your email is {$profile->email} and social network - {$userOAuth->provider}<br />";
}
$userOAuth = UserOAuth::model()->findUser(5, "Google"); // find all authorizations from user with id=5
$profile = $userOAuth->profile;
echo "Your email is {$profile->email} and social network - {$userOAuth->provider}<br />";
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.