本文整理汇总了PHP中Social::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Social::get方法的具体用法?PHP Social::get怎么用?PHP Social::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Social
的用法示例。
在下文中一共展示了Social::get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getObject
public static function getObject()
{
$class = get_called_class();
$class = substr($class, strrpos($class, '\\') + 1);
$object = Social::get($class, 'object_name');
return $object;
}
示例2: action_login
public function action_login()
{
//if user loged in redirect home
if (Auth::instance()->logged_in()) {
Auth::instance()->login_redirect();
}
Social::include_vendor();
$user = FALSE;
$config = Social::get();
if ($this->request->query('hauth_start') or $this->request->query('hauth_done')) {
try {
Hybrid_Endpoint::process($this->request->query());
} catch (Exception $e) {
Alert::set(Alert::ERROR, $e->getMessage());
$this->redirect(Route::url('default'));
}
} else {
$provider_name = $this->request->param('id');
try {
// initialize Hybrid_Auth with a given file
$hybridauth = new Hybrid_Auth($config);
// try to authenticate with the selected provider
if ($provider_name == 'openid') {
$params = array('openid_identifier' => 'https://openid.stackexchange.com/');
} else {
$params = NULL;
}
$adapter = $hybridauth->authenticate($provider_name, $params);
if ($hybridauth->isConnectedWith($provider_name)) {
//var_dump($adapter->getUserProfile());
$user_profile = $adapter->getUserProfile();
}
} catch (Exception $e) {
Alert::set(Alert::ERROR, __('Error: please try again!') . " " . $e->getMessage());
$this->redirect(Route::url('default'));
}
//try to login the user with same provider and identifier
$user = Auth::instance()->social_login($provider_name, $user_profile->identifier);
//we couldnt login create account
if ($user == FALSE) {
$email = $user_profile->emailVerified != NULL ? $user_profile->emailVerified : $user_profile->email;
$name = $user_profile->firstName != NULL ? $user_profile->firstName . ' ' . $user_profile->lastName : $user_profile->displayName;
//if not email provided
if (!Valid::email($email, TRUE)) {
Alert::set(Alert::INFO, __('We need your email address to complete'));
//redirect him to select the email to register
$this->redirect(Route::url('default', array('controller' => 'social', 'action' => 'register', 'id' => $provider_name)) . '?uid=' . $user_profile->identifier . '&name=' . $name);
} else {
//register the user in DB
Model_User::create_social($email, $name, $provider_name, $user_profile->identifier);
//log him in
Auth::instance()->social_login($provider_name, $user_profile->identifier);
}
} else {
Alert::set(Alert::SUCCESS, __('Welcome!'));
}
$this->redirect(Session::instance()->get_once('auth_redirect', Route::url('default')));
}
}
示例3: action_index
public function action_index()
{
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Social Authentication for login')));
$this->template->title = __('Social Auth');
$this->template->styles = array('css/sortable.css' => 'screen');
$this->template->scripts['footer'][] = 'js/jquery-sortable-min.js';
//retrieve social_auth values
$config = Social::get();
if ($p = $this->request->post()) {
$confit_old = $config;
$config_new = array();
foreach ($p as $key => $value) {
if ($key != 'submit') {
// check if its id, secret .. and build multy d. array, same as they have
if (strpos($key, '_id')) {
$config_new['providers'][str_replace('_id', '', $key)]['keys']['id'] = $value;
} elseif (strpos($key, '_secret')) {
$config_new['providers'][str_replace('_secret', '', $key)]['keys']['secret'] = $value;
} elseif (strpos($key, '_key')) {
$config_new['providers'][str_replace('_key', '', $key)]['keys']['key'] = $value;
} elseif ($key == 'debug_mode') {
$config_new[$key] = $value;
} else {
$config_new['providers'][$key]['enabled'] = $value;
}
}
}
// two fields not included
$config_new['base_url'] = Route::url('default', array('controller' => 'social', 'action' => 'login', 'id' => 1));
$config_new['debug_file'] = DOCROOT . 'oc/vendor/hybridauth/logs.txt';
$obj_social_config = new Model_Config();
$conf = $obj_social_config->where('group_name', '=', 'social')->where('config_key', '=', 'config')->limit(1)->find();
if ($conf->loaded()) {
$conf->config_value = json_encode($config_new);
try {
$conf->save();
$config = $config_new;
//we update the form values if we changed them
Alert::set(Alert::SUCCESS, __('Social Auth updated'));
} catch (Exception $e) {
throw HTTP_Exception::factory(500, $e->getMessage());
}
}
}
$this->template->content = View::factory('oc-panel/pages/social_auth/index', array('config' => $config));
}