public function resolve($link) { return Routes::detail($link->getId(), $link->getSlug(), Prismic::context()->getRef()); }
<?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()); }
require_once LIBRARIES_PATH . "/Prismic.php"; // this loads our Prismic helpers, which include the prismic.io PHP kit $ctx = Prismic::context(); // getting the context built from our configuration (like the Api object it initializes) global $linkResolver; // getting the linkResolver object (more on this later) /* Controller */ try { // API calls $homepage = Prismic::getDocument($ctx->getApi()->bookmark('homepage')); $skills = $ctx->getApi()->forms()->skills->ref($ctx->getRef())->submit(); $works = $ctx->getApi()->forms()->works->ref($ctx->getRef())->submit(); $stuffido = $ctx->getApi()->forms()->{"stuff-i-do"}->ref($ctx->getRef())->submit(); $kindsofwork = $ctx->getApi()->forms()->everything->query('[[:d = at(document.type, "kind-of-work")]]')->ref($ctx->getRef())->submit(); } catch (Guzzle\Http\Exception\BadResponseException $e) { Prismic::handlePrismicException($e); // We need to catch any network issue, and render it properly } ?> <!DOCTYPE html> <html lang="en-US" class="no-js"> <head> <!-- ============================================== Title and Meta Tags =============================================== --> <meta charset="utf-8"> <title>prismic.io's Bootstrap3 example</title> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<?php require_once '../resources/config.php'; require_once LIBRARIES_PATH . "/Prismic.php"; $api = Prismic::apiHome(); $maybeClientId = Prismic::config('prismic.clientId'); $maybeClientSecret = Prismic::config('prismic.clientSecret'); if (!isset($maybeClientId)) { throw new Exception("Please provide clientId"); } if (!isset($maybeClientSecret)) { throw new Exception("Please provide clientSecret"); } $params = array("client_id" => Prismic::config('prismic.clientId'), "redirect_uri" => Prismic::callback(), "scope" => "master+releases"); $queryString = http_build_query($params); header('Location: ' . $api->oauthInitiateEndpoint() . '?' . $queryString, false, 301); exit(0);