本文整理汇总了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';
}
}
示例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));
}