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


PHP Profile::whereUid方法代碼示例

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


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

示例1: vkcallback

 public function vkcallback()
 {
     // Init OAuth 2.0 proxy
     $oauth2Proxy = new Oauth2Proxy(Config::get("vk.appId"), Config::get("vk.secret"), 'https://oauth.vk.com/access_token', 'https://oauth.vk.com/authorize', 'code', 'http://' . $_SERVER['HTTP_HOST'] . '/login/vkcallback', 'offline,notify,friends,photos,audio,video,wall');
     // Try to authorize client
     if ($oauth2Proxy->authorize() === true) {
         // Init vk.com SDK
         $vkPhpSdk = new VkPhpSdk();
         $vkPhpSdk->setAccessToken($oauth2Proxy->getAccessToken());
         $vkPhpSdk->setUserId($oauth2Proxy->getUserId());
         // API call - get profile
         $result = $vkPhpSdk->api('getProfiles', array('uids' => $vkPhpSdk->getUserId(), 'fields' => 'uid, first_name, last_name, nickname, screen_name, photo_big, email, photo'));
     } else {
         // handle error exception here
         die("error");
         return redirect('/');
     }
     $accessToken = $oauth2Proxy->getAccessToken();
     if (!@$result['response'][0]['uid']) {
         die($result[0]['uid']);
         return redirect('/');
     }
     $vkUid = $result['response'][0]['uid'];
     $gotoProfileCompletePage = false;
     $profile = Profile::whereUid($vkUid)->first();
     if (empty($profile)) {
         $user = new User();
         $user->name = $result['response'][0]['first_name'] . ' ' . $result['response'][0]['last_name'];
         $user->email = $result['response'][0]['screen_name'];
         $user->photo_large = $result['response'][0]['photo_big'];
         $user->photo_small = $result['response'][0]['photo'];
         $user->save();
         $profile = new Profile();
         $profile->uid = $vkUid;
         $profile->username = $result['response'][0]['screen_name'];
         $profile->origin = 'vk';
         $profile->access_token = $accessToken;
         $profile->access_token_secret = $accessToken;
         $profile = $user->profiles()->save($profile);
         // first time, need to complete profile
         $gotoProfileCompletePage = true;
     }
     $profile->access_token = $accessToken;
     $profile->save();
     $user = $profile->user;
     Auth::login($user);
     if ($gotoProfileCompletePage) {
         return redirect('/login/complete');
     } else {
         return redirect('/');
     }
 }
開發者ID:algobasket,項目名稱:eve-online-project,代碼行數:52,代碼來源:AuthController.php


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