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


PHP JSON::error方法代码示例

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


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

示例1: handle

 function handle(&$params)
 {
     $app =& Dataface_Application::getInstance();
     if (!@$_POST['-valuelist']) {
         echo JSON::error("No valuelist specified.");
         exit;
     }
     $valuelist = $_POST['-valuelist'];
     $query =& $app->getQuery();
     $table =& Dataface_Table::loadTable($query['-table']);
     if (!@$_POST['-value']) {
         echo JSON::error("No value was provided to be appended to the valuelist.");
         exit;
     }
     $value = $_POST['-value'];
     if (@$_POST['-key']) {
         $key = $_POST['-key'];
     } else {
         $key = null;
     }
     $vt =& Dataface_ValuelistTool::getInstance();
     $res = $vt->addValueToValuelist($table, $valuelist, $value, $key, true);
     if (PEAR::isError($res)) {
         echo JSON::error($res->getMessage());
         exit;
     }
     echo JSON::json(array('success' => 1, 'value' => array('key' => $res['key'], 'value' => $res['value'])));
     exit;
 }
开发者ID:minger11,项目名称:Pipeline,代码行数:29,代码来源:ajax_valuelist_append.php

示例2: throwRateError

 public static function throwRateError($retryAfter = null, $error = 'Rate limit exceeded')
 {
     header('HTTP/1.1 429 Too Many Requests');
     if ($retryAfter) {
         header("Retry-After: {$retryAfter}");
         $error .= ", retry after {$retryAfter} seconds";
     }
     \JSON::error($error);
 }
开发者ID:jmealo,项目名称:Gatekeeper,代码行数:9,代码来源:ApiRequestHandler.php

示例3: header

<?php

namespace Gatekeeper;

$Endpoint = $_EVENT['request']->getEndpoint();
if ($Endpoint->DeprecationDate && $Endpoint->DeprecationDate < $_EVENT['request']->getStartTime()) {
    header('HTTP/1.1 410 Gone');
    \JSON::error('This endpoint+version has been deprecated');
}
开发者ID:jmealo,项目名称:Gatekeeper,代码行数:9,代码来源:35_reject-deprecated-endpoint.php

示例4: catch

<?php

namespace Gatekeeper;

use Gatekeeper\Keys\Key;
use Gatekeeper\Keys\InvalidKeyException;
// load key if present
try {
    if ($Key = Key::getFromRequest()) {
        $_EVENT['request']->setKey($Key);
    }
} catch (InvalidKeyException $e) {
    \JSON::error('provided gatekeeper key is invalid', 401);
}
开发者ID:jmealo,项目名称:Gatekeeper,代码行数:14,代码来源:40_load-key.php

示例5:

<?php

namespace Gatekeeper;

$Key = $_EVENT['request']->getKey();
if ($Key && $Key->ExpirationDate && $Key->ExpirationDate < $_EVENT['request']->getStartTime()) {
    \JSON::error('provided gatekeeper key is expired', 403);
}
开发者ID:jmealo,项目名称:Gatekeeper,代码行数:8,代码来源:53_reject-expired-key.php

示例6: array

<?php

$GLOBALS['Session']->requireAccountLevel('Developer');
$requestData = JSON::getRequestData();
if (!is_array($requestData['nodes'])) {
    JSON::error('Expecting array under nodes key');
}
// TODO: something more elegant to prevent non-specified classes from being inherited?
Site::$autoPull = true;
$succeeded = array();
$failed = array();
foreach ($requestData['nodes'] as $updateData) {
    $Node = Site::resolvePath($updateData['path']);
    if ($Node->Collection->Site == 'Local') {
        $failed[] = array('path' => $updateData['path'], 'error' => 'CURRENT_IS_LOCAL', 'message' => 'Current node is local and blocks any remote updates');
        continue;
    }
    if ($Node->SHA1 != $updateData['localSHA1']) {
        $failed[] = array('path' => $updateData['path'], 'error' => 'LOCAL_SHA1_MISMATCH', 'message' => 'Current node\'s SHA1 hash does not match that which this update was requested for');
        continue;
    }
    if (empty($updateData['remoteSHA1'])) {
        $Node->delete();
    } else {
        $NewNode = Emergence::resolveFileFromParent($Node->Collection, $Node->Handle, true);
        if (!$NewNode) {
            $failed[] = array('path' => $updateData['path'], 'error' => 'DOWNLOAD_FAILED', 'message' => 'The remote file failed to download');
            continue;
        }
        if ($NewNode->SHA1 != $updateData['remoteSHA1']) {
            $NewNode->destroyRecord();
开发者ID:nbey,项目名称:Emergence-Skeleton,代码行数:31,代码来源:pull-remote-changes.php

示例7:

<?php

namespace Gatekeeper;

$Key = $_EVENT['request']->getKey();
if ($Key && $Key->Status == 'revoked') {
    \JSON::error('provided gatekeeper key is revoked', 403);
}
开发者ID:jmealo,项目名称:Gatekeeper,代码行数:8,代码来源:52_reject-revoked-key.php

示例8: header

<?php

namespace Gatekeeper;

$Endpoint = $_EVENT['request']->getEndpoint();
$Key = $_EVENT['request']->getKey();
if ($Endpoint->KeyRequired) {
    if (!$Key) {
        $realm = Gatekeeper::$authRealm;
        if ($Endpoint) {
            $realm .= '/';
        }
        header(sprintf('WWW-Authenticate: %s/%s', Gatekeeper::$authRealm, $Endpoint->Path));
        \JSON::error('gatekeeper key required for this endpoint but not provided', 401);
    }
    if (!$Key->canAccessEndpoint($Endpoint)) {
        \JSON::error('provided gatekeeper key does not grant access to this endpoint', 403);
    }
}
开发者ID:jmealo,项目名称:Gatekeeper,代码行数:19,代码来源:55_reject-missing-key.php

示例9:

<?php

namespace Gatekeeper;

use Gatekeeper\Bans\Ban;
$Key = $_EVENT['request']->getKey();
if ($Key && Ban::isKeyBanned($Key)) {
    \JSON::error('Your API key is currently banned from using this service', 403);
}
开发者ID:jmealo,项目名称:Gatekeeper,代码行数:9,代码来源:54_reject-banned-key.php

示例10: array_merge

// add keywords query
if (!empty($_GET['q'])) {
    $where = array_merge($where, ASAPSearch::getKeywordConditions($_GET['q']));
}
// add ASAP clubs filter
if (!empty($_GET['clubs'])) {
    $clubs = is_array($_GET['clubs']) ? $_GET['clubs'] : [$_GET['clubs']];
    $where = array_merge($where, ASAPSearch::getClubConditions($clubs));
}
// add distance calculation / order
if (!empty($_GET['near'])) {
    if (!is_array($_GET['near']) || empty($_GET['near']['lat']) || empty($_GET['near']['lon'])) {
        JSON::error('near must be provided as an array with keys lat and lon');
    }
    if (!is_numeric($_GET['near']['lat']) || !is_numeric($_GET['near']['lon'])) {
        JSON::error('lat and lon must be numeric');
    }
    $selectFields[] = sprintf('ROUND(((ACOS( SIN(%1$f * PI()/180 ) * SIN(SiteLat * PI()/180 ) + COS(%1$f * PI()/180 ) * COS(SiteLat * PI()/180 ) * COS((%2$f - SiteLong) * PI()/180))*180/PI())*60*1.1515),%3$u) AS distance', $_GET['near']['lat'], $_GET['near']['lon'], 2);
    $order = 'distance';
} else {
    $order = 'SiteZip, SiteName';
}
// add grades filter
if (!empty($_GET['grades'])) {
    $validGrades = ['Pre_k', 'K_5', '6_8', '9_12', 'Other'];
    $grades = is_array($_GET['grades']) ? $_GET['grades'] : [$_GET['grades']];
    foreach ($validGrades as $validGrade) {
        if (in_array($validGrade, $grades)) {
            $where[] = "SiteGrade_{$validGrade} = 1";
        }
    }
开发者ID:CfABrigadePhiladelphia,项目名称:asap-mobile,代码行数:31,代码来源:asap-search.php

示例11: header

<?php

namespace Gatekeeper;

use Gatekeeper\Bans\Ban;
if (Ban::isIPAddressBanned($_SERVER['REMOTE_ADDR'])) {
    header('HTTP/1.1 403 Forbidden');
    \JSON::error('Your IP address is currently banned from using this service');
}
开发者ID:jmealo,项目名称:Gatekeeper,代码行数:9,代码来源:15_reject-banned-ip.php


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