Ejemplo n.º 1
0
<?php

require_once '../lib/setup.php';
$nf = new NationalField(NF_APISAMPLE_KEY, NF_APISAMPLE_SECRET, 'basic');
if (isset($_POST['action'])) {
    // login/logout
    switch ($_POST['action']) {
        case 'login':
            $nf->setClient($_POST['client']);
            $nf->redirectForAuthentication();
            break;
        case 'logout':
            $nf->clearAuthentication();
            break;
    }
} elseif (isset($_GET['code'])) {
    // authorization response
    if ($nf->completeAuthentication($_GET['code'])) {
        header('location: ' . $_SERVER['PHP_SELF']);
        exit;
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>NationalField API Sample</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link href="css/bootstrap.min.css" rel="stylesheet">
Ejemplo n.º 2
0
<?php

require_once '../lib/setup.php';
$nf = new NationalField(NF_APISAMPLE_KEY, NF_APISAMPLE_SECRET, 'iframe');
if (!$nf->isAuthenticated()) {
    $url = $nf->getAuthenticationUrl();
    // use javascript to framebust
    echo '<script type="text/javascript">top.location.href="' . $url . '";</script>';
    exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>NationalField iframe Sample</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    
    <link href="css/bootstrap.min.css" rel="stylesheet">
</head>

<body>
    <div class="container">
        <h1>NationalField iframe Sample</h1>
        <?php 
$user = $nf->api('users/me');
?>
        <h2><?php 
echo htmlentities($user['displayName']);
?>
</h2>