Skip to content

Instantly share code, notes, and snippets.

@thanhhh
Created November 17, 2015 08:21
Show Gist options
  • Save thanhhh/0c1094e85efca4b37584 to your computer and use it in GitHub Desktop.
Save thanhhh/0c1094e85efca4b37584 to your computer and use it in GitHub Desktop.
Get user access token using Facebook SDK for PHP
<?php
require_once __DIR__ . '/vendor/autoload.php';
session_start();
$fbData = array(
'app_id' => '{APP ID}',
'app_secret' => '{APP SECRET}',
'profile_id' => '{PAGE ID}',
'default_graph_version' => 'v2.5',
);
$fb = new Facebook\Facebook($fbData);
$params = array('req_perms' => 'manage_pages, publish_pages, public_profile');
$helper = $fb->getRedirectLoginHelper();
$loginUrl = $helper->getLoginUrl('http://fbsamples.local/callback.php', $params);
header('Location: '. $loginUrl);
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment