コード例 #1
0
require_once 'vendor/autoload.php';
require_once __DIR__ . '/Config.php';
require_once __DIR__ . '/GoogleSheet.php';
use Lib\Common;
use Google\Spreadsheet\DefaultServiceRequest;
use Google\Spreadsheet\ServiceRequestFactory;
$serviceRequest = new DefaultServiceRequest(Common::getGoogleTokenFromKeyFile());
ServiceRequestFactory::setInstance($serviceRequest);
$spreadsheetFeed = GoogleSheet::getAllSpreadSheetFeed();
/*
 * Facebook Area
 */
$fbApp = new Facebook\FacebookApp(FACEBOOK_API_KEY, FACEBOOK_API_SECRET);
$fb = new Facebook\Facebook(['app_id' => FACEBOOK_API_KEY, 'app_secret' => FACEBOOK_API_SECRET, 'default_graph_version' => 'v2.5']);
if (isset($_SESSION['facebook_access_token']) && $_SESSION['facebook_access_token']) {
    $fb_user_id = \Lib\FacebookApi::getMe()['id'];
    //\Lib\FacebookApi::getUserGroup($fb_user_id);
} else {
    $fb_user_id = '';
    $helper = $fb->getRedirectLoginHelper();
    $permissions = ['email', 'user_posts'];
    // optional
    $callback = FACEBOOK_CALLBACK;
    $loginUrl = $helper->getLoginUrl($callback, $permissions);
}
?>

<!DOCTYPE html>
<html lang="">
<head>
	<meta charset="utf-8">
コード例 #2
0
<?php

/**
 * Created by PhpStorm.
 * User: hungnguyen
 * Date: 02/03/16
 * Time: 4:06 PM
 */
session_start();
ini_set('max_execution_time', 1200);
//300 seconds = 5 minutes
ini_set('memory_limit ', '521M');
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../GoogleSheet.php';
require_once __DIR__ . '/../Config.php';
use Google\Spreadsheet\DefaultServiceRequest;
use Google\Spreadsheet\ServiceRequestFactory;
use Lib\Common;
use Lib\FacebookApi;
$serviceRequest = new DefaultServiceRequest(Common::getGoogleTokenFromKeyFile());
ServiceRequestFactory::setInstance($serviceRequest);
$post_spreadSheetFeed = $_POST['spreadSheet'];
$post_workSheet = $_POST['worksheet'];
$_post_fbID = $_POST['facebook_user_id'];
$facebookListFeeds = FacebookApi::getListFeeds($_post_fbID, LIMIT_ITEM_PERPAGE);
// 50 is limit row for each query. We can change to the value we need
//Insert data into Google Sheet
GoogleSheet::addListRow($post_spreadSheetFeed, $post_workSheet, $facebookListFeeds);
echo json_encode(['status' => true]);