本文整理匯總了PHP中BigTree::apiEncode方法的典型用法代碼示例。如果您正苦於以下問題:PHP BigTree::apiEncode方法的具體用法?PHP BigTree::apiEncode怎麽用?PHP BigTree::apiEncode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類BigTree
的用法示例。
在下文中一共展示了BigTree::apiEncode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: apiValidateToken
function apiValidateToken($token)
{
$t = sqlfetch(sqlquery("SELECT * FROM bigtree_api_tokens WHERE token = '{$token}'"));
if (!$t) {
echo BigTree::apiEncode(array("success" => false, "error" => "Token is invalid."));
return false;
}
if ($t["temporary"] && strtotime($t["expires"]) < time()) {
echo BigTree::apiEncode(array("success" => false, "error" => "Token has expired."));
return false;
}
// If it's a temporary token, update its expiration to keep it fresh.
if ($t["temporary"]) {
sqlquery("UPDATE bigtree_api_tokens SET expires = '" . date("Y-m-d H:i:s", strtotime("+30 minutes")) . "' WHERE id = '" . $t["id"] . "'");
}
$user = $this->getUser($t["user"]);
$this->ID = $user["id"];
$this->User = $user["email"];
$this->Level = $user["level"];
$this->Name = $user["name"];
$this->Permissions = $user["permissions"];
$this->ReadOnly = $t["read_only"];
return true;
}