These are some handy queries you will need when building Facebook Apps. As I work on Facebook stuff building out FanPageEngine tool and building various Facebook Apps, I spend hours figuring this stuff out so I don’t want it to vanish after I use it. Bookmark this page. I will be adding more and more to it as I find new nuggets of useful code.

CURL Code For Getting Data From Facebook Graph API
<?php
function getsomeinfo($id,$token) {
$url = "https://graph.facebook.com/YOUR_QUERY_HERE;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: graph.facebook.com'));
$output1 = curl_exec($ch);
curl_close($ch);
return $output;
}
$thedata = json_decode(getsomeinfo(PAGE_ID/USER_ID,ACCESS_TOKEN),true);
?>

List of Apps Already Installed On A Page
https://graph.facebook.com/PAGE_ID/tabs?access_token=PAGE_ACCESS_TOKEN

Need A Page_Access_Token? Here Is How To Get It
https://graph.facebook.com/PAGE_ID/?fields=access_token&access_token=ACCESS_TOKEN

Get Information About A Given Page
https://graph.facebook.com/PAGE_ID/?metadata=1&access_token=ACCESS_TOKEN

Connect To Facebook From A Web Page
<?php
session_start();
if($_GET['pros'] == '1') {
if(isset($_SESSION['access_token']) && isset($_SESSION['uid'])) {
$graph_url = "https://graph.facebook.com/me?" .
"access_token=" . $_SESSION['access_token'];
$_SESSION['ai'] = $ai;
$session = $_SESSION;
$uid = $_SESSION['uid'];
$me = json_decode(file_get_contents($graph_url), true);
}
}
if(!$me) {
$url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] :
"http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
$url = $url.'&pros=1';
$loginUrl = 'https://www.facebook.com/dialog/oauth?'
. 'client_id=YOUR_APP_ID&redirect_uri='.$uuurl.'&'
. 'scope=email,manage_pages,OTHER_PERMISSIONS_REQUEST_LIST&'
. 'response_type=token';
echo '<center><a href="'.$loginUrl.'">'
. '<img src="http://static.ak.fbcdn.net/rsrc.php/zB6N8/hash/4li2k73z.gif" border="0">'
. '</a></center>';
} else {
echo "Hello ".$me['first_name'];
}
?>




Digg It
Vote It Up
Retweet It
Share It
Bookmark It





