Skip to content

Instantly share code, notes, and snippets.

@rotten77
Created June 17, 2013 08:48
Show Gist options
  • Save rotten77/5795528 to your computer and use it in GitHub Desktop.
Save rotten77/5795528 to your computer and use it in GitHub Desktop.
<?php
define('APP_ID', ''); // Your App's ID
define('APP_SECRET', ''); // Your App's Secret
define('PAGE_URN', ''); // http://facebook.com/YOUR_PAGE_URN
define('APP_URL', 'http://'); // Your App's registered domain
/**
* Get acces_token for API
*/
$getToken = 'https://graph.facebook.com/oauth/access_token?client_id=' . APP_ID . '&client_secret=' . APP_SECRET . '&grant_type=client_credentials&redirect_uri=' . APP_URL;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $getToken);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$accessToken = curl_exec($curl);
/**
* Get page feed
*/
$getFeed = 'https://graph.facebook.com/' . PAGE_URN . '/feed?' . $accessToken;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $getFeed);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$jsonFeed = curl_exec($curl);
$jsonData = json_decode($jsonFeed);
var_dump($jsonData);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment