Пример #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

ini_set('display_errors', 1);
error_reporting(E_ALL);
$config = array('social' => array('facebook' => array('id' => '{fb-app-id}', 'secret' => '{fb-app-secret}', 'redirect' => '{your-site-callback-url}', 'scope' => array('{scope1}', '{scope2}', '{scope3}')), 'vk' => array('id' => '{vk-app-id}', 'secret' => '{vk_app-secret}', 'redirect' => '{your-site-callback-url}', 'scope' => array('{scope1}', '{scope2}'))));
session_start();
require_once "vendor/autoload.php";
\Social\Factory::setConfig($config['social']);
$social = \Social\Factory::factory($_GET['social']);
if (isset($_GET['code'])) {
    $social->setCode($_GET['code']);
    echo "<pre>";
    var_dump($social->getUserData());
    die("</pre>");
} else {
    header('Location: ' . $social->getLoginUrl());
    exit;
}
Пример #3
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;
}