本文整理汇总了PHP中Routes::index方法的典型用法代码示例。如果您正苦于以下问题:PHP Routes::index方法的具体用法?PHP Routes::index怎么用?PHP Routes::index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Routes
的用法示例。
在下文中一共展示了Routes::index方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isset
<?php
require_once '../resources/config.php';
require_once LIBRARIES_PATH . "/Prismic.php";
$maybeCode = isset($_GET['code']) ? $_GET['code'] : null;
if (!isset($maybeCode)) {
header('HTTP/1.1 400 Bad Request', true, 400);
exit('Bad Request');
}
$maybeRedirectUri = isset($_GET['redirect_uri']) ? $_GET['redirect_uri'] : null;
$api = Prismic::apiHome();
$data = array("grant_type" => array('authorization_code'), "code" => $maybeCode, "redirect_uri" => Prismic::callback(), "client_id" => Prismic::config("prismic.clientId"), "client_secret" => Prismic::config("prismic.clientSecret"));
try {
$response = Prismic\Api::getClient()->post($api->oauthTokenEndpoint(), null, $data)->send();
$url = isset($maybeRedirectUri) ? $maybeRedirectUri : Routes::index();
$json = $response->json();
setcookie('ACCESS_TOKEN', $json['access_token']);
header('Location: ' . $url);
} catch (Guzzle\Http\Exception\BadResponseException $e) {
header('HTTP/1.0 401 Unauthorized');
exit($response->getStatusCode());
}
示例2: setcookie
<?php
require_once '../resources/config.php';
setcookie('ACCESS_TOKEN', "", time() - 1);
header('Location: ' . Routes::index());
示例3: handlePrismicException
public static function handlePrismicException($e)
{
$response = $e->getResponse();
if ($response->getStatusCode() == 403) {
header('Location: ' . Routes::signin());
exit('Forbidden');
} elseif ($response->getStatusCode() == 401) {
setcookie('ACCESS_TOKEN', "", time() - 1);
header('Location: ' . Routes::index());
exit('Unauthorized');
} elseif ($response->getStatusCode() == 404) {
header("HTTP/1.0 404 Not Found");
exit("Not Found");
} else {
echo $response->getStatusCode();
exit($response->getStatusCode());
}
}