本文整理汇总了PHP中Api::testPrivateToken方法的典型用法代码示例。如果您正苦于以下问题:PHP Api::testPrivateToken方法的具体用法?PHP Api::testPrivateToken怎么用?PHP Api::testPrivateToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Api
的用法示例。
在下文中一共展示了Api::testPrivateToken方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getBaseURL
require_once "lib/private/api.php";
require_once "lib/private/out.class.php";
Out::writeHeadersXML();
echo '<rss version="2.0">';
// Build RSS header
$BaseURL = getBaseURL();
$Out = new Out();
$Out->pushValue("title", "Raidplaner RSS feed");
$Out->pushValue("link", $BaseURL . "index.php");
$Out->pushValue("description", "Upcoming raids for the next 2 weeks.");
$Out->pushValue("language", "en-en");
$Out->pushValue("copyright", "packedpixel");
$Out->pushValue("pubDate", date(DATE_RSS));
// Requires private token to be visible
$Token = isset($_REQUEST["token"]) ? $_REQUEST["token"] : null;
if (Api::testPrivateToken($Token)) {
// Setting the correct timezones
$Timezone = isset($_REQUEST["timezone"]) ? $_REQUEST["timezone"] : date_default_timezone_get();
// Query API
date_default_timezone_set("UTC");
$Parameters = array("start" => time() - 24 * 60 * 60, "end" => time() + 14 * 24 * 60 * 60, "limit" => 0, "closed" => true, "canceled" => true);
$Locations = Api::queryLocation(null);
$Raids = Api::queryRaid($Parameters);
$LocationName = array();
foreach ($Locations as $Location) {
$LocationName[$Location["Id"]] = $Location["Name"];
}
// Generate RSS content
date_default_timezone_set($Timezone);
foreach ($Raids as $Raid) {
$Start = date("H:i", intval($Raid["Start"]));
示例2: api_help
// Generate response
$Out = Out::getInstance();
if (isset($_REQUEST['help'])) {
api_help($_REQUEST);
} else {
if (!isset($_REQUEST['query'])) {
$Out->pushError('You must at least provide the parameter `query` and a `token`.');
$Out->pushError('You can also pass `help` with a topic to see a list of available parameters.');
} else {
$Authenticated = false;
$NormalizeFunc = 'api_args_' . strtolower($_REQUEST['query']);
$Parameter = function_exists($NormalizeFunc) ? call_user_func($NormalizeFunc, $_REQUEST) : null;
// Validate against public or private token
// If no token is given, try to validate the currently logged in user.
if (isset($_REQUEST['token'])) {
$Authenticated = Api::testPrivateToken($_REQUEST['token']) || Api::testPublicToken($Parameter, $_REQUEST['token']);
}
// Only execute requests if validated
if (!$Authenticated) {
$Out->pushError('Validation failed.');
} else {
switch (strtolower($_REQUEST['query'])) {
case 'location':
$Out->pushValue('result', api_query_location($Parameter));
break;
case 'user':
$Out->pushValue('result', api_query_user($Parameter));
break;
case 'raid':
$Out->pushValue('result', api_query_raid($Parameter));
break;