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


PHP REST::created方法代码示例

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


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

示例1: Exception

DELETE `Tokens`, `TokenValues`
FROM `Tokens` NATURAL JOIN `TokenValues` 
WHERE `Tokens`.`tokenId` = {$delete}
  AND `poolId` = {$poolId};
EOS
);
            if (!Topos::mysqli()->affected_rows) {
                throw new Exception("Token {$deleteTokenId} not found", REST::HTTP_NOT_FOUND);
            }
        } catch (Exception $e) {
            Topos::real_query("DELETE FROM `Tokens` WHERE `tokenId` = {$tokenId};");
            REST::fatal($e->getCode(), $e->getMessage());
        }
    }
    $tokenURL = Topos::urlbase() . 'pools/' . REST::urlencode($TOPOS_POOL) . '/tokens/' . $tokenId;
    REST::created($tokenURL);
}
REST::require_method('HEAD', 'GET');
$nameClause = is_string(@$_GET['name']) && strlen($_GET['name']) ? "AND MATCH(`tokenName`) AGAINST (" . Topos::escape_string($_GET['name']) . " IN BOOLEAN MODE)" : '';
if ((int) @$_GET['timeout'] > 0) {
    $timeout = (int) $_GET['timeout'];
    if ($timeout < 1) {
        REST::fatal(REST::HTTP_BAD_REQUEST, 'Illegal value for parameter "timeout"');
    }
    $escDescription = isset($_GET['description']) ? Topos::escape_string((string) $_GET['description']) : "''";
    $lockUUID = Topos::uuid();
    $timeout = <<<EOS
, `tokenLockTimeout` = UNIX_TIMESTAMP() + {$timeout}
, `tokenLockUUID` = '{$lockUUID}'
, `tokenLockDescription` = {$escDescription}
EOS;
开发者ID:sara-nl,项目名称:ToPoS,代码行数:31,代码来源:nextToken.php

示例2: elseif

    if ($_SERVER['REQUEST_METHOD'] === 'PUT' && @$_GET['mode'] === 'create' && $handle->read()) {
        REST::fatal(REST::HTTP_PRECONDITION_FAILED, 'Handle exists.');
    } elseif ($_SERVER['REQUEST_METHOD'] === 'PUT' && @$_GET['mode'] === 'update' && !$handle->delete()) {
        REST::fatal(REST::HTTP_PRECONDITION_FAILED, 'Handle doesn\'t exist.');
    } else {
        $handle->delete();
    }
    // Store the data...
    $handle->create();
    // and return the proper response:
    switch ($_SERVER['REQUEST_METHOD']) {
        case 'PUT':
            REST::fatal(REST::HTTP_OK);
            break;
        case 'POST':
            REST::created(REST::urlbase() . CP::PORTAL_URL . urlencode($CP_PREFIX) . '/' . urlencode($CP_SUFFIX));
            break;
        default:
            // this shouldn't happen
            REST::fatal(REST::HTTP_INTERNAL_SERVER_ERROR);
    }
} elseif ($_SERVER['REQUEST_METHOD'] === 'DELETE') {
    $handle = new CP_Handle("{$CP_PREFIX}/{$CP_SUFFIX}");
    REST::fatal($handle->delete() ? REST::HTTP_OK : REST::HTTP_NOT_FOUND);
} else {
    // If we're here, the request method should be GET or HEAD. Otherwise, quit:
    REST::require_method('GET', 'HEAD');
    // Create a CP_Handle object...
    $handle = new CP_Handle("{$CP_PREFIX}/{$CP_SUFFIX}");
    // and read its contents from the database. If it's not there...
    if (!$handle->read()) {
开发者ID:CatchPlus,项目名称:CATCHPlus-Handle-Service,代码行数:31,代码来源:handle.php

示例3: exec

EOS
);
    exec("cd '{$sandbox}'; find -mindepth 1 -maxdepth 1 -print0 | xargs -0 tar zcf {$TEMPNAM}.tgz", $output, $return_var);
    if ($return_var) {
        $output = implode("\n", $output);
        REST::fatal(REST::HTTP_INTERNAL_SERVER_ERROR, $output);
    }
    $tokenhandle = fopen("{$TEMPNAM}.tgz", 'r');
    try {
        $token_url = Topos::putTokenFile($tokenhandle, 'application/x-compressed-tar');
    } catch (Exception $e) {
        fclose($tokenhandle);
        throw $e;
    }
    fclose($tokenhandle);
    $token_id = basename($token_url);
    Portal_MySQL::real_query(<<<EOS
INSERT INTO `Token`
       ( `token_id`,  `user_id` )
VALUES ( {$token_id}, {$user_id} );
EOS
);
    $resultURL = REST::urlbase() . Portal::portalURL() . "jobstates/{$token_id}";
    REST::created($resultURL);
}
Portal_User::current();
REST::header(array('Content-Type' => REST::best_xhtml_type()));
echo Portal::html_start("{$appname}-{$appversion}") . '<form action="' . $appversion . '" method="post" enctype="multipart/form-data">';
$portlet->doGET();
echo '</form>' . Portal::html_end();
开发者ID:CatchPlus,项目名称:CATCHPlus-Handle-Service,代码行数:30,代码来源:application.php


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