当前位置: 首页>>代码示例>>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;未经允许,请勿转载。