当前位置: 首页>>代码示例>>PHP>>正文


PHP UserData::writeUser方法代码示例

本文整理汇总了PHP中UserData::writeUser方法的典型用法代码示例。如果您正苦于以下问题:PHP UserData::writeUser方法的具体用法?PHP UserData::writeUser怎么用?PHP UserData::writeUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserData的用法示例。


在下文中一共展示了UserData::writeUser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fetchInfo

 public function fetchInfo()
 {
     global $srkEnv;
     $code = $_GET['code'];
     $data = (object) array('client_id' => $srkEnv->thirdPartyLogin['github']->clientId, 'client_secret' => $srkEnv->thirdPartyLogin['github']->clientSecret, 'code' => $code, 'accept' => 'json');
     $postRes = decipherGetStr(webPostData('https://github.com/login/oauth/access_token', $data));
     if (isset($postRes['access_token'])) {
         $accessToken = $postRes['access_token'];
         $dataStr = webGetData('https://api.github.com/user?access_token=' . $accessToken);
         $userInfo = json_decode($dataStr);
         if (!$userInfo) {
             return 'Data fetching error';
         }
         $userData = (object) array('userId' => 'github_' . $userInfo->login, 'email' => $userInfo->email, 'nickname' => $userInfo->name, 'accessToken' => $accessToken, 'avatarURL' => $userInfo->avatar_url, 'source' => 'github');
         $user = new UserData();
         $user->registerThirdParty($userData);
         $writeRes = $user->writeUser();
         if (!$writeRes) {
             $_SESSION['userId'] = $userData->userId;
         }
         return $writeRes;
     } else {
         return 'Access code error';
     }
 }
开发者ID:laekov,项目名称:shiruku,代码行数:25,代码来源:github.php

示例2: UserData

     $user = new UserData();
     $user->readUser($userId);
     $authRes = $user->authenticate($passwd);
     if ($authRes === false) {
         $_SESSION['userId'] = $user->id;
         srkSend((object) array('res' => 'successful'));
     } else {
         srkSend((object) array('res' => $authRes));
     }
 } elseif ($srkEnv->reqURLLength == 3 && $srkEnv->reqURL[3] == 'register') {
     $user = new UserData();
     $regRes = $user->register($_POST['userId'], $_POST);
     if ($regRes->res !== false) {
         srkSend($regRes);
     } else {
         $writeRes = $user->writeUser();
         if ($writeRes === false) {
             $_SESSION['userId'] = $user->id;
             srkSend((object) array('res' => 'successful'));
         } else {
             srkSend((object) array('res' => 'Failed to write data'));
         }
     }
 } elseif ($srkEnv->reqURLLength == 3 && $srkEnv->reqURL[3] == 'logout') {
     unset($_SESSION['userId']);
     srkSend((object) array('res' => 'successful'));
 } elseif ($srkEnv->reqURLLength == 3 && $srkEnv->reqURL[3] == 'edit') {
     $user = new UserData();
     $user->readUser($_SESSION['userId']);
     srkSend($user->update($_POST));
 }
开发者ID:laekov,项目名称:shiruku,代码行数:31,代码来源:login.php


注:本文中的UserData::writeUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。