<?php
session_start();

require_once __DIR__ . '/vendor/autoload.php';

$config = require_once __DIR__ . '/hybridauth_config.php';

if (isset($_GET['provider'])) {
    $provider = $_GET['provider'];

    try {
        $hybridauth = new Hybridauth\Hybridauth($config);
        $adapter = $hybridauth->authenticate($provider);
        header('Location: hybridauth_callback.php?provider=' . $provider);
    } catch (Exception $e) {
        echo 'Oops, we ran into an issue: ' . $e->getMessage();
    }
} else {
    echo 'Provider not specified.';
}
