Пример #1
0
<?php

require __DIR__ . '/bootstrap.php';
$token = null;
$user = null;
$error = null;
if (isset($_SESSION['auth'])) {
    $token = $_SESSION['auth'];
}
if ($token) {
    $api = \Social\Factory::getInstance()->createApi($token);
    $user = $api->getProfile();
    if (!$user) {
        $error = $api->getError();
    }
}
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="static/main.css">
    <title>Base example</title>
</head>
<body>
<div class="tst">

    <?php 
if ($error) {
    ?>
        <div class="error"><?php 
Пример #2
0
<?php

require __DIR__ . '/bootstrap.php';
try {
    $type = _GET('type');
    $auth = \Social\Factory::getInstance()->createAuth($type);
    $url = $auth->getAuthorizeUrl($REDIRECT_URL . '?type=' . $type);
    stopAndRedirect($url);
} catch (Exception $e) {
    echo 'Error: ' . $e->getMessage();
    exit;
}