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


PHP Routes::index方法代码示例

本文整理汇总了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());
}
开发者ID:stymjs0515,项目名称:prismicio-bootstrap-example,代码行数:22,代码来源:callback.php

示例2: setcookie

<?php

require_once '../resources/config.php';
setcookie('ACCESS_TOKEN', "", time() - 1);
header('Location: ' . Routes::index());
开发者ID:stymjs0515,项目名称:prismicio-bootstrap-example,代码行数:5,代码来源:signout.php

示例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());
     }
 }
开发者ID:stymjs0515,项目名称:prismicio-bootstrap-example,代码行数:18,代码来源:Prismic.php


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