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


PHP Api::testPrivateToken方法代码示例

本文整理汇总了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"]));
开发者ID:zatoshi,项目名称:raidplaner,代码行数:31,代码来源:feed.php

示例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;
开发者ID:zatoshi,项目名称:raidplaner,代码行数:31,代码来源:apihub.php


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