示例#1
0
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">
    <style>
        body {