コード例 #1
0
ファイル: get_profile.php プロジェクト: PacoHobi/ed_companion
<?php

require_once 'classes/EDAPI.php';
$api = new EDAPI();
$info = $api->getProfile();
if ($info['http_code'] != 200) {
    echo 'ERROR: Not logged in';
} else {
    echo $info['content'];
}
コード例 #2
0
ファイル: login.php プロジェクト: PacoHobi/ed_companion
<?php

include_once 'classes/EDAPI.php';
$api = new EDAPI();
$email = isset($_POST['email']) ? $_POST['email'] : '';
$password = isset($_POST['password']) ? $_POST['password'] : '';
$errors = array();
if ($email && $password) {
    $info = $api->login($email, $password);
    if ($info['http_code'] == 302) {
        header('Location: confirm.php');
    } else {
        $errors[] = "Email or password are incorrect";
    }
} else {
    $errors[] = "Email and Password are both required fields";
}
?>

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>ED Companion</title>
  </head>
  <body>
    <?php 
if (sizeof($errors)) {
    echo '<h3>Errors</h3><ul>';
    foreach ($errors as $error) {
        echo '<li>' . $error . '</li>';
コード例 #3
0
ファイル: confirm.php プロジェクト: PacoHobi/ed_companion
<?php

include_once 'classes/EDAPI.php';
include_once 'classes/Utils.php';
$api = new EDAPI();
$code = isset($_POST['code']) ? $_POST['code'] : '';
$errors = array();
if ($code) {
    $info = $api->confirm($code);
    if (endsWith($info['redirect_url'], '.net/')) {
        header('Location: index.php');
    } else {
        $errors[] = "Code incorrect";
    }
}
?>

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>ED Companion</title>
  </head>
  <body>
    <?php 
if (sizeof($errors)) {
    echo '<h3>Errors</h3><ul>';
    foreach ($errors as $error) {
        echo '<li>' . $error . '</li>';
    }
    echo '</ul>';