Exemplo n.º 1
0
<?php

require "bootstrap.php";
$fb_config = (include "config_facebook.php");
$db_config = (include "db_config.php");
$fb = new Facebook\Facebook($fb_config);
$dashboardFb = new DashboardSocial\DashboardFacebook();
$dashboardFb->setFacebook($fb);
$pdo = new PDO($db_config["dsn"], $db_config["username"], $db_config["password"], $db_config["option"]);
$dashboardSv = new DashboardSocial\DashBoardService();
$dashboardSv->setPDO($pdo);
$userToken = $dashboardFb->getUserLoginToken();
if ($dashboardFb->getTokenExpire($userToken) >= time()) {
    header("Location: index.php");
}
$fb->setDefaultAccessToken($userToken);
$response = $fb->get('/me?fields=id,accounts{access_token,name,id}');
$graphEdge = $response->getGraphNode();
$data = $graphEdge->asArray();
$accounts = $data['accounts'];
$userId = $data['id'];
$pages = $dashboardSv->getPages($userId);
$pages_unsave = array_filter($accounts, function ($item) use($pages) {
    foreach ($pages as $page) {
        if ($page['facebook_page_id'] == $item['id']) {
            return false;
        }
    }
    return true;
});
?>
Exemplo n.º 2
0
<?php

require "bootstrap.php";
$config = (include "config_facebook.php");
$fb = new Facebook\Facebook($config);
$dashboardFb = new \DashboardSocial\DashboardFacebook();
$dashboardFb->setFacebook($fb);
try {
    $accessToken = $dashboardFb->getUserLoginToken();
} catch (Facebook\Exceptions\FacebookResponseException $e) {
    echo 'Graph returned an error: ' . $e->getMessage();
    exit;
} catch (Facebook\Exceptions\FacebookSDKException $e) {
    echo 'Facebook SDK returned an error: ' . $e->getMessage();
    exit;
}
?>
<html>
<head>
	<meta charset="utf-8">
	<script type="text/javascript" src="public/jquery/jquery-1.11.3.min.js"></script>
</head>
<body>
<div id="body"></div>
<script type="text/javascript">
$(function(){
	window.hasLogin = function(){
		var $a = $('<a href="facebook_page_list.php">goto page</a>');
		$('#body').html($a);
	};
	var isLogin = <?php 
Exemplo n.º 3
0
<?php

require "bootstrap.php";
$fb_config = (include "config_facebook.php");
$db_config = (include "db_config.php");
$fb = new Facebook\Facebook($fb_config);
$dashboardFb = new DashboardSocial\DashboardFacebook();
$dashboardFb->setFacebook($fb);
$pdo = new PDO($db_config["dsn"], $db_config["username"], $db_config["password"], $db_config["option"]);
$dashboardSv = new DashboardSocial\DashBoardService();
$dashboardSv->setPDO($pdo);
$userToken = $dashboardFb->getUserLoginToken();
if ($dashboardFb->getTokenExpire($userToken) >= time()) {
    header("Location: index.php");
}
$response = $fb->get('/me?fields=id', $userToken);
$user = $response->getGraphNode()->asArray();
$longliveToken = $dashboardFb->extendLongliveAccessToken($_GET['access_token']);
$response = $fb->get('/me?fields=id,name', $longliveToken);
$page = $response->getGraphNode()->asArray();
$dashboardSv->addPage($page["id"], $longliveToken, $user["id"], $page["name"]);
header("Location: facebook_page_list.php?ts=" . time());
Exemplo n.º 4
0
<?php

require "bootstrap.php";
$config = (include "config_facebook.php");
$fb = new Facebook\Facebook($config);
$dashboardFb = new \DashboardSocial\DashboardFacebook();
$dashboardFb->setFacebook($fb);
try {
    $accessToken = $dashboardFb->getAccessToken();
} catch (Facebook\Exceptions\FacebookResponseException $e) {
    echo 'Graph returned an error: ' . $e->getMessage();
    exit;
} catch (Facebook\Exceptions\FacebookSDKException $e) {
    echo 'Facebook SDK returned an error: ' . $e->getMessage();
    exit;
}
if (isset($accessToken)) {
    $dashboardFb->setAccessToken((string) $accessToken);
    echo <<<SCRIPT
<script>
window.opener.hasLogin();
window.close();
</script>
SCRIPT;
} else {
    $loginUrl = $dashboardFb->getLoginUrl(BASE_URL . "login.php");
    header("Location: " . $loginUrl);
}