當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserIdentity::authenticateWeibo方法代碼示例

本文整理匯總了PHP中UserIdentity::authenticateWeibo方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserIdentity::authenticateWeibo方法的具體用法?PHP UserIdentity::authenticateWeibo怎麽用?PHP UserIdentity::authenticateWeibo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UserIdentity的用法示例。


在下文中一共展示了UserIdentity::authenticateWeibo方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: loginBySina

 public function loginBySina()
 {
     $SAEOAuth = Yii::app()->SAEOAuth;
     $client = $SAEOAuth->getSinaClient();
     $sina_id = $SAEOAuth->getUserID();
     $sina_info = $client->show_user($sina_id);
     $model = new WeiboForm();
     $user = $model->getUserBySinaID($sina_id);
     if (empty($user)) {
         if (Yii::app()->user->isGuest or 1) {
             $username = $sina_id;
             $password = '123456';
             $model->username = $sina_id;
             $model->password = $password;
             $model->verifyPassword = $password;
             $soucePassword = $model->password;
             $model->activkey = UserModule::encrypting(microtime() . $model->password);
             $model->password = UserModule::encrypting($model->password);
             $model->verifyPassword = UserModule::encrypting($model->verifyPassword);
             $model->superuser = 0;
             $model->status = Yii::app()->controller->module->activeAfterRegister ? User::STATUS_ACTIVE : User::STATUS_NOACTIVE;
             $model->sina_id = $sina_id;
             $model->email = $sina_id . '@hhb.com';
             $model->save();
             $user = $model;
         } else {
             $user = User::model()->findByPk(Yii::app()->user->id);
             $user->sina_id = $sina_id;
             $user->save();
         }
     }
     $profile = $user->profile;
     if (empty($profile)) {
         $profile = new Profile();
         $profile->user_id = $model->id;
     }
     $profile->name = $sina_info['name'];
     $profile->location = $sina_info['location'];
     $profile->current_province = $sina_info['province'];
     $profile->current_city = $sina_info['city'];
     $profile->avatar = $sina_info['profile_image_url'];
     $profile->save();
     $username = $user->username;
     $password = $user->password;
     $identity = new UserIdentity($username, $password);
     $identity->authenticateWeibo();
     //必須設置默認時間,才能多域名共享登錄session
     $duration = $this->rememberMe ? 3600 * 24 * 30 : 0;
     // 30 days
     Yii::app()->user->login($identity, $duration);
 }
開發者ID:vangogogo,項目名稱:justsns,代碼行數:51,代碼來源:WeiboForm.php


注:本文中的UserIdentity::authenticateWeibo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。