Download - PHP Graph API Beginner's Tutorial

Transcript

Start uncommenting each part of the code you will understand more easily how everything works.I think it will help people who are anxious to "get their hands dirty" right away

I will include three(3) files:

First we have the header. I guess this is standard code, changed slightly between applications, and necessary on every page to ensure facebook login etc.

Code:

<?phprequire_once $_SERVER["DOCUMENT_ROOT"] . '/facebook-php-sdk/src/facebook.php';$nl = "<br/>"; //newline$appId = 'xxxxxxxxxxxxxxxxxxxxxxx'; //change as necessary$appUrl = "http://apps.facebook.com/app/"; //change as necessary$baseUrl = "http://example.com/app/"; //change as necessary

// Create our Application instance.$facebook = new Facebook(array( 'appId' => $appId, 'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', //change as necessary 'cookie' => true,));

$session = $facebook->getSession();

$fbme = null;// Session based graph API call.if (!$session){ $login_url = $facebook->getLoginUrl ( array ( "canvas" => true, "fbconnect" => false, //"req_perms" => "user_birthday, user_interests, user_hometown", ) ); echo "<script type='text/javascript'>top.location.href = '" . $login_url. "';</script>";}?>

Secondly we have the CSS which includes a lot of facebook styles which a lot of you will find it very usefull if you wish to create facebook look-alike applications.

Code:

/* Facebook styles *//*Facebook uses four major colors in its colorpalette. As you design your UI, you want to besure to use these to better emulate the look ofFacebook. These include white and four shadesof blue. Here are the colors’ hex values: hexvalues: #ffffff (white), #d8dfea (lightest blue),#afbdd4 (lighter blue), #6d84b4 (darker blue),and #3b5998 (darkest blue).*//**********************************************************BASIC FORMATTING************************************************************/body{ background: #fff; font-family: "Lucida Grande", Tahoma, Verdana, Arial, sans-serif; font-size: 11px; margin: 0px; padding: 0px; text-align: left;}

h1, h2, h3, h4, h5{ font-size: 13px; color: #333; margin: 0px; padding: 0px;}h1 { font-size: 14px; }h4, h5 { font-size: 11px; }

p{ font-family: "Lucida Grande", Tahoma, Verdana, Arial, sans-serif; font-size: 11px; text-align: left;}

a{

color: #3b5998; text-decoration: none;}a:hover { text-decoration: underline; }

img { border: 0px; }

select{ border: 1px solid #BDC7D8; font-family: "Lucida Grande", Tahoma, Verdana, Arial, sans-serif; font-size: 11px; padding: 2px;}

td, td.label{ font-size: 11px; text-align: left;}

.canvasContent { margin: 10px 20px 5px 10px; } /* here is defined a new class */ /*THIS LINE FORCES US TO LOSE SPACE FROM CANVAS, MAYBE IT IS REDUNDANT AND SHOULD BE REMOVED*/

/******************************************************FACEBOOK INPUT BUTTON********************************************************************/.inputbutton{ border-style: solid; border-top-width: 1px; border-left-width: 1px; border-bottom-width: 1px; border-right-width: 1px; border-top-color: #D9DFEA; border-left-color: #D9DFEA; border-bottom-color: #0e1f5b; border-right-color: #0e1f5b; background-color: #3b5998; color: #ffffff; font-size: 11px; font-family: "Lucida Grande", Tahoma, Verdana, Arial, sans-serif; padding: 2px 15px 3px 15px; text-align: center;}

/******************************************************FACEBOOK LINK BUTTON********************************************************************/

a.link_btn_style{ color: #fff; font-size: 13px; outline: none; display:block; height:25px;}

html[xmlns] a.link_btn_style{ display:table;}

a.link_btn_style div, a.link_btn_style span /*declare bottom left*/{ cursor:pointer; float:left; line-height:15px; padding: 0px 0px 2px 0px; background-repeat: no-repeat; background-position: bottom left;}a.link_btn_style div div /*declare top right*/{ /*here we have nested in two levels. under the link_btn_style we should have two divs */ padding:0px 2px 0px 0px; /*top, left, right, bottom*/ background-position: top right;}a.link_btn_style div div div /*declare top left*/{ padding:0px; background-position: top left;}a.link_btn_style span.btn_text /*declare bottom right*/{ display:block; /* notice that the bottom right position is block because we want a break line for the next html element after this button */ margin:2px -2px -2px 2px; padding:2px 19px 5px 17px; /*top, left, right, bottom*/ background-position: bottom right; }

* html a.link_btn_style span { position:relative; }

a.reg_btn_style div /* default view */{

background-image: url(http://www.facebook.com/images/welcome/btn_register_signup_active_bg.gif);}a.reg_btn_style span.btn_text{ color:#fff; font-weight:normal;}a.reg_btn_style:link div, a.reg_btn_style:link span, a.reg_btn_style:visited div, a.reg_btn_style:visited span /* visited view */{ background-image: url(http://www.facebook.com//images/welcome/btn_register_signup_bg.gif);}a.reg_btn_style:active div, a.reg_btn_style:active span /* active view (when we press down the click button) */{ background-image: url(http://www.facebook.com//images/welcome/btn_register_signup_active_bg.gif);}

/*******************************************************TWO-COLUMNS LIST*************************************************************/.lists th{ background: #6d84b4; text-align: left; padding: 5px 10px; }

.lists .spacer{ background: none; border: none; padding: 0px; margin: 0px; width: 10px;}

.lists th h4{ float: left; color: white;}

.lists th a

{ float: right; font-weight: normal; color: #d9dfea;}

.lists th a:hover{ color: white;}

.lists td{ margin:0px 10px; padding:0px; vertical-align:top; width:306px;}

.lists .list{ background: white none repeat scroll 0%; border-color: -moz-use-text-color #BBBBBB; border-style: none solid; border-width: medium 1px;}

.lists .list .list_item{ border-top:1px solid #E5E5E5; padding: 10px;}

.lists .list .list_item.first{ border-top: none;}

.lists .see_all{ background: white none repeat scroll 0%; border-color: -moz-use-text-color #BBBBBB rgb(187, 187, 187); border-style: none solid solid; border-width: medium 1px 1px; text-align: left;}

.lists .see_all div

{ border-top:1px solid #E5E5E5; padding:5px 10px;}

/**********************************************************DASHBOARD************************************************************/.fb-dashboard { padding: 10px 10px 0px; }.fb-dashboard .fb-links{ padding: 0px 10px 5px; /* top, left and right, bottom. Bottom value has been corrected from 5px to 18px*/ border-bottom: solid 1px #ccc;}.fb-dashboard .fb-links .fb-actions { float: left; }.fb-dashboard .fb-links .fb-help { float: right; }.fb-dashboard .fb-links .pipe{ padding: 0px 7px; color: #aaa;}.fb-dashboard .fb-links form{ display: inline; overflow: hidden; width: 0px;}.fb-dashboard .fb-titlebar{ padding: 10px 10px 12px; /*top, left and right, bottom*/}.fb-dashboard .fb-titlebar h2{ background-repeat: no-repeat; background-position: 1px 8px; float: left; font-size: 14px; padding: 7px 0px 7px 24px;}.fb-dashboard .fb-create-button-wrapper{ float: right; margin: 7px 0px 0px 10px; background: url(http://www.facebook.com/images/new_media_button_active.gif) no-repeat bottom;}

/* fb-create-button */.fb-create-button{ display: block; float: left; color: #777; text-decoration: none; background: url(http://www.facebook.com/images/new_media_button.gif) no-repeat;}.fb-create-button .tr { background: url(http://www.facebook.com//images/new_media_button.gif) no-repeat top right; }.fb-create-button .bl { background: url(http://www.facebook.com//images/new_media_button.gif) no-repeat bottom left; }.fb-create-button .br { background: url(http://www.facebook.com//images/new_media_button.gif) no-repeat bottom right; }

.fb-create-button span{ background: url(http://www.facebook.com/images/new_media_button_plus.gif) no-repeat 9px center; color: #333; font-size: 11px; font-weight: bold; display: block; padding: 3px 9px 5px 22px; text-shadow: white 0px 1px 1px;}

.fb-create-button:hover { text-decoration: underline; }

.fb-create-button:active, .fb-create-button:active .tr, .fb-create-button:active .bl,

.fb-create-button:active .br{ background-image: url(http://www.facebook.com/images/new_media_button_active.gif);}

.clearfix:after{ content: "."; display: block; clear: both;

visibility: hidden; line-height: 0; height: 0;}/*.clearfix { display: inline-block; }*/ /*this has been omitted due to bad results in formatting*/

html[xmlns] .clearfix { display: block; }* html .clearfix { height: 1%; }

/**********************************************************NAVIGATION TABS************************************************************/.fb-tabs{ border-bottom: 1px solid #898989; padding: 3px 0px; /* top and bottom, left and right */}.fb-tabs .left_tabs{ float: left; padding-left: 10px;}.fb-tabs .right_tabs{ float: right; padding-right: 10px;}

.fb-tabitems{ display: inline; list-style: none; margin: 0; padding: 0; text-align: center;}

.fb-tabitems li{ display: inline; padding: 2px 0px 3px; /*top, left and right, bottom*/ background: #f1f1f1 url(http://www.facebook.com/images/components/toggle_tab_gloss.gif) top left repeat-x;}

.fb-tabitems li a

{ border: 1px solid #898989; color: #333; font-weight: bold; padding: 2px 8px 3px 9px;}

.fb-tabitems li a small{ font-size: 11px; font-weight: normal;}

.fb-tabitems li a:focus{ outline: 0px;}

.fb-tabitems li.first a /*only for the first anchor of the list*/{ border:1px solid #898989;}

.fb-tabitems li a.selected{ background: #6d84b4; border: 1px solid #3b5998; border-left: 1px solid #5973a9; border-right: 1px solid #5973a9; color: #fff; margin-left: -1px;}

.fb-tabitems li.last a.selected{ margin-left:-1px; border-left:1px solid #5973a9; border-right:1px solid #36538f;}

.fb-tabitems li.first.last a.selected{ border: 1px solid #36538f;}

.fb-tabitems li a.selected:hover{ text-decoration: none;

}

/**********************************************************SUBTITLE REGION************************************************************/.subtitle{ border-bottom: 1px solid #D8DFEA; clear: both; padding: 11px 20px 0px; color: black; font-weight: normal; line-height: normal;}.subtitle .caption{ color: #333; float: left; padding-top: 3px; padding-bottom: 4px;}

and last but not least the main part of the code you will be more interested in, is this:

Code:

<?phprequire_once("header.php");//session_start();?><link rel="stylesheet" type="text/css" href="fbstyle.css" />

<div id="canvas" class="canvasContent"><?php$query = "SELECT uid FROM userWHERE uid=me()";$FQL = array ( "method" => "fql.query", "query" => $query);$datas = $facebook->api($FQL);out($datas[0][uid]);?>

<h1>App site</h1><h2>h2 header</h2><h3>h3 header</h3><h4>h4 header</h4><h5>h5 header</h5>

<!--body part-->body part<br />

<a>if you click here nothing will happen :P</a>

<p>paragraph</p>

<select> <option value="first">First Option</option> <option value="second">Second Option</option></select>

<br />

<table border="1"> <tr> <td>Hello</td> <td>Today</td> </tr> <tr> <td>Sup</td> <td>Dude</td> </tr></table>

<br />

<div class="fb-dashboard"> <div class="fb-links clearfix"> <div class="fb-actions"> <a href="#">Action Link 1</a> <span class="pipe">|</span> <a href="#">Action Link 2</a> <span class="pipe">|</span> <a href="#">Action Link 3</a> </div> <div class="fb-help"> <a href="#">Help</a> </div> </div> <div class="fb-titlebar clearfix"> <h2 style="background-image:url('http://static.ak.facebook.com/images/icons/photo.gif?55:25796')">My iframe Application</h2> <div class="fb-create-button-wrapper">

<a href="#" class="fb-create-button"> <div class="tr"> <div class="bl"> <div class="br"> <span>Create Something</span> </div> </div> </div> </a> </div> </div></div>

<div class="fb-tabs clearfix"> <center> <div class="left_tabs"> <ul class="fb-tabitems clearfix"> <li><a href="#">NavbarLink1</a></li> <li><a href="#" class="selected">NavbarLink2</a></li> <li><a href="#">NavbarLink3</a></li> </ul> </div> <div class="right_tabs"> <ul class="fb-tabitems clearfix"> <li><a href="#">NavbarLink1Right</a></li> <li><a href="#">NavbarLink2Right</a></li> </ul> </div> </center></div>

<div class="subtitle clearfix"> <div class="caption">This is a place for captions and subtitles.</div></div>

<br />

<input type="button" class="inputbutton" value="Do Action"/>

<br /><br />

<div> <a href="#" class="link_btn_style reg_btn_style"> <div> <div> <div> <span class="btn_text">Click Me</span>

</div> </div> </div> </a></div>

<br />

<div> <table class="lists" cellspacing="0" border="0"> <tr> <th> <!-- special table row element which is Table Header. normally on top of tables --> <h4>List 1</h4> <a href="#">See All1</a> </th> <th class="spacer"> </th> <th> <h4>List 2</h4> <a href="#">See All2</a> </th> </tr> <tr> <td class="list"> <div class="list_item clearfix"> Aenean felis purus, ullamcorper sed, laoreet quis, porttitor et, mauris. Donec blandit dictum dui. Cras magna erat, sagittis vitae, ornare quis, dignissim eget, orci. Sed viverra nisl nec erat. Ut vulputate. Sed vitae elit sed nisi condimentum fringilla. Proin dapibus dui ac tellus. </div> </td> <td class="spacer"> </td> <td class="list"> <div class="list_item clearfix"> Nulla in tellus tempor mauris euismod bibendum. Vestibulum metus quam, tincidunt sed, gravida pretium, vulputate a, augue. Maecenas tempus metus a nulla. Nullam sollicitudin, lorem ut ultricies ultricies, est ipsum vulputate nunc, vel feugiat mi sem in erat. </div> </td> </tr> <tr> <td class="see_all"> <div>

<a href="#">See all List 1’s</a> </div> </td> <td class="spacer"> </td> <td class="see_all"> <div> <a href="#">See all List 2’s</a> </div> </td> </tr> </table></div>

<br />

<script type='text/javascript'>function topLink(aUrl){ top.location.href = aUrl;}</script>

<?php //functionsfunction getPermUrl($redirectUrl, $perms){ global $appId; $permUrl = "https://graph.facebook.com/oauth/authorize?client_id="; $permUrl = $permUrl . $appId; $permUrl = $permUrl . "&redirect_uri="; $permUrl = $permUrl . $redirectUrl; $permUrl = $permUrl . "&scope="; $permUrl = $permUrl . $perms; //user_photos,user_videos,publish_stream return $permUrl;}function areFriends($uidLeft, $uidRight){ $query = " SELECT uid1,uid2 FROM friend WHERE uid1 = $uidLeft AND uid2 = $uidRight "; $FQL = array ( "method" => "fql.query", "query" => $query); $datas = $facebook->api($FQL); if($datas) return true; else return false;

}function out($json){ echo "<pre>"; print_r($json); echo "</pre>";}?>

<?phptry{ //$uid = $facebook->getUser(); $fbme = $facebook->api("/me?fields=name,picture"); /* // login or logout url will be needed depending on current user state. if($fbme) { $logoutUrl = $facebook->getLogoutUrl(); echo "<a href='". $logoutUrl . "'>click here to logout</a>" .$nl; } else { $loginUrl = $facebook->getLoginUrl(); echo "<a href='". $loginUrl . "'>click here to login</a>" .$nl; } if($fbme) { //https://graph.facebook.com/oauth/authorize?client_id=174209505930964&redirect_uri=http://apps.facebook.com/giorgosapp/&scope=user_likes $movies = $facebook->api('/me/movies'); //http://bit.ly/gODpya <--- here is the solution how to check for permission with FQL echo $fbme["id"].$nl; echo $fbme["name"].$nl; } //$arr = array("one", "two", "three"); //echo $movies["data"][0]["name"]; foreach ($movies["data"] as $mov) { echo $mov["name"] . $nl; } echo "This is my email: ";

if (!$fbme["email"]) //if we do not have the permission then this is zero { $emailPerm = getPermUrl($appUrl,"email"); echo "<a href='' onclick=\"topLink('" . $emailPerm . "')\">click here to get email</a>" .$nl; } else { echo $fbme["email"] .$nl; } //update user's status using graph api if(isset($_POST['tt'])) { $msg = array ( //'access_token' => "YUR ACCESS TOKEN", //'name' => "This is the title of my post", //'link' => "http://blogs.canalplan.org.uk/steve/2010/04/28/hitting-a-moving-target/", //'description' => "this is the body of the post with lots of wiffly woffly text in it, lets see if this all works ok!", //'picture'=>"http://blogs.canalplan.org.uk/steve/files/2009/12/13742_1291940983817_1389037839_836473_2130235_n.jpg", 'message' => $_POST['tt'], 'cb' => '', //to callback function protimoume na einai null, ektos an theloume na kanoume refresh thn selida h na metavoume se kapoia allh ); $facebook->api('/me/feed', 'POST', $msg); } */}catch (FacebookApiException $e) { echo '<pre>'; print_r($e); echo '</pre>'; }

//$accessToken = $facebook->getAccessToken();//echo $accessToken ."<br/>";?><br /><img src="<?=$fbme["picture"]?>" />

<!--<form name="" action="<?=$baseUrl?>" method="post"> <label for="tt">Status update using Graph API</label><br /> <textarea id="tt" name="tt" cols="50" rows="2">Write your status here and click 'submit'</textarea>

<br /> <input type="submit" value="update status" /></form>--><?phptry //status{ /* $curstatus = $facebook->api('/me/statuses?limit=1'); //check last status if(!$curstatus) { //echo "no feed" .$nl; $feedPerm = getPermUrl($appUrl,"publish_stream"); echo "<a href='' onclick=\"topLink('" . $feedPerm . "')\">click here to grand access to your status</a>" .$nl; } else { echo "my last status is: "; echo $curstatus["data"][0]["message"] .$nl; } */ //get status of all friends of current user $myfriends = $facebook->api("/me/friends"); if($myfriends["data"][0]) { $count=0; foreach($myfriends["data"] as $friend) { /* //GRAPH API //$curStatus = $facebook->api("/$friend[id]/statuses?limit=1"); $curStatus = $facebook->api("statuses?ids=$friend[id]&limit=1"); //$curStatus = $curStatus[$friend["id"]]; echo "$friend[name] says $curStatus[data]" .$nl; print_r($curStatus); echo $nl.$nl; */ //WE DO NOT HAVE ACCESS TO STATUSES OF OTHER USERS DIRECTLY. CHECK IT FOR YOURSELF AND LET ME KNOW IF YOU FIND A WORKAROUND at [email protected] /* //legacy api $desired_details = array('last_name','first_name', 'status'); $param = array( 'method' => 'users.getInfo', 'uids' => $friend["id"],

'fields' => $desired_details, 'callback'=> '' ); $getInfo = $facebook->api($param); print_r($getInfo); echo $nl; */ $count+=1; if($count>=5) break; } } }catch (FacebookApiException $e) { echo '<pre>'; print_r($e); echo '</pre>'; }?>

<br />

<?phptry //friends{ /* echo "You have a bunch of friends in facebook." . $nl; echo "Here is the top 5:"; echo "<ul>"; $myfriends = $facebook->api('/me/friends'); $count=1; foreach ($myfriends["data"] as $frnd) { echo "<li>" . $frnd["name"]. "</li>" .$nl; if($count>=5) break; $count+=1; } echo "</ul>" //print_r($myfriends); //human readable information */}catch (FacebookApiException $e) { echo '<pre>'; print_r($e); echo '</pre>'; }?>

<?phptry //change top location in facebook browser (with javascript){ /* $somelink = "http://www.in.gr";

echo "<a href='' onclick=\"topLink('" . $somelink . "')\">click here to change top location</a>" .$nl; */}catch (FacebookApiException $e) { echo '<pre>'; print_r($e); echo '</pre>'; }

try //LEGACY REST API{ $uid1 = "xxxxxxxxxxxxxx"; //friend $uid2 = "xxxxxxxxxxxxxx"; //friend $uid3 = "xxxxxxxxxxxxxx"; //friend $uid4 = "xxxxxxxxxxxxxx"; //friend $uid5 = "xxxxxxxxxxxxxx"; //not a friend $uid6 = "xxxxxxxxxxxxxx"; //not a friend /* $param = array( 'method' => 'friends.areFriends', 'uids1' => $uid1, 'uids2' => $uid3, 'callback'=> '' ); $areFriends = $facebook->api($param); print_r($areFriends); echo $nl; */}catch (FacebookApiException $e) { echo '<pre>'; print_r($e); echo '</pre>'; }

try //events{ $snowball = 161905923847953; //$eventPerm = getPermUrl($appUrl,"user_events"); //echo "<a href='' onclick=\"topLink('" . $eventPerm . "')\">give application access to your events</a>" .$nl; //$friendsEventPerm = getPermUrl($appUrl,"friends_events"); //echo "<a href='' onclick=\"topLink('" . $friendsEventPerm . "')\">allow application to access your friends' events</a>" .$nl; /* $friendEvent = $facebook->api("/$uid1/events"); echo "To proto apo ta event enos friend (edw ths thalias): " . $friendEvent["data"][0]["name"] .$nl; $snowballEvent = $facebook->api($snowball); echo "now trying to get all the members of the event " . $snowballEvent["name"] . ":" .$nl;

$sbattending = $facebook->api("/$snowball/attending"); //print_r($sbattending); if($sbattending["data"][0]) //necessary check before a foreach loop to avoid fatal error { foreach($sbattending["data"] as $attendant) { echo $attendant["name"] . $nl; } } */}catch (FacebookApiException $e) { echo '<pre>'; print_r($e); echo '</pre>'; }

try //groups{ $thraknes = 2246288569; /* $groupPerm = getPermUrl($appUrl,"user_groups"); echo "<a href='' onclick=\"topLink('" . $groupPerm . "')\">allow this application to access your groups</a>" .$nl; $friendsGroupPerm = getPermUrl($appUrl,"friends_groups"); echo "<a href='' onclick=\"topLink('" . $friendsGroupPerm . "')\">allow application to access the groups of all your friends</a>" .$nl; */ /* $thraknesGroup = $facebook->api("/$thraknes?fields=name,members"); //get extra fields, not available by default //print_r( array_keys($thraknesGroup["members"]["data"]) ); foreach($thraknesGroup["members"]["data"] as $member) { echo $member["name"] .$nl; } */ /* $friendGroups = $facebook->api("/$uid3/groups"); echo "all aspasoulini's groups:" . $nl; foreach($friendGroups["data"] as $group) { echo $group["name"] . $nl; } */}

catch (FacebookApiException $e) { echo '<pre>'; print_r($e); echo '</pre>'; }

try //facebook pages{ /* $likesPerm = getPermUrl($appUrl,"user_likes,friends_likes"); echo "<a href='' onclick=\"topLink('" . $likesPerm . "')\">allow application to access your pages and the pages of your friends</a>" .$nl; */ /* echo "facebook pages" .$nl; $myPages = $facebook->api("/$uid1/likes?fields=name"); //friend's user id here */ /* if($myPages["data"][0]) { foreach($myPages["data"] as $page) { echo "The page " . $page["name"] . " has " . $page["fan_count"] . " members" . $nl; } } */ /* $json = array(); $json["name"] = "EasyJet"; //$json["fan_count"] = "42971"; $json["id"] = "11936918897"; $json["created_time"] = "2010-09-14T21:20:11+0000"; //print_r($myPages["data"]); $key = array_search($json,$myPages["data"]); //array search using objects. cool! echo "the key is: " . $key . $nl; //print_r($myPages["data"]); */ }catch (FacebookApiException $e) { echo '<pre>'; print_r($e); echo '</pre>'; }?>

<?php //FQLtry{ /*//name of single user

$query = " SELECT name FROM user WHERE uid=$fbme[id] "; $FQL = array ( "method" => "fql.query", "query" => $query); $data = $facebook->api($FQL); print_r($data); echo $nl; */ /*//all members of a group $query = " SELECT uid FROM group_member WHERE gid=$thraknes "; $FQL = array ( "method" => "fql.query", "query" => $query); $data = $facebook->api($FQL); print_r($data); echo $nl; */ /*//all movies of a user $query = " SELECT name, movies FROM user WHERE uid=$fbme[id] "; $FQL = array ( "method" => "fql.query", "query" => $query); $datas = $facebook->api($FQL); foreach($datas[0] as $data) { echo $data .$nl; } */ /*//info about an event $query = " SELECT eid, venue.city FROM event WHERE eid=$snowball "; $FQL = array ( "method" => "fql.query", "query" => $query); $datas = $facebook->api($FQL); foreach($datas[0] as $data) { if(!is_array($data)) echo $data .$nl; else { $key = array_keys($datas[0],$data); echo $key[0] .$nl; foreach($data as $dt) { echo "...." . $dt .$nl; } }

} print_r($datas); */ /*//using operators in where clause $query = " SELECT eid FROM event_member WHERE uid=$fbme[id] AND eid>=7630890908 "; $FQL = array ( "method" => "fql.query", "query" => $query); $datas = $facebook->api($FQL); if($datas[0]) foreach($datas[0] as $data) { if(!is_array($data)) echo $data .$nl; else { $key = array_keys($datas[0],$data); echo $key[0] .$nl; foreach($data as $dt) { echo "...." . $dt .$nl; } } } */ /*//IN clause $query = " SELECT name, location FROM event WHERE eid IN ( SELECT eid FROM event_member WHERE uid=$fbme[id] ) "; $FQL = array ( "method" => "fql.query", "query" => $query); $datas = $facebook->api($FQL); if($datas[0]) foreach($datas[0] as $data) { if(!is_array($data)) echo $data .$nl; else { $key = array_keys($datas[0],$data); echo $key[0] .$nl; foreach($data as $dt)

{ echo "...." . $dt .$nl; } } } */ //the friend map // $query = "// SELECT uid1, uid2// FROM friend// WHERE uid1 IN (SELECT uid1 FROM friend WHERE uid2=$fbme[id])// AND uid2 IN (SELECT uid1 FROM friend WHERE uid2=$fbme[id])// AND uid1 < uid2// ";

//all of my friends who are females// $query = "// SELECT name FROM user// WHERE sex='female' AND uid IN// (// SELECT uid1 FROM friend// WHERE uid2=$fbme[id]// )// "; //all the pages that i am fan of// $query = "// SELECT name FROM page// WHERE page_id IN// (// SELECT page_id FROM page_fan// WHERE uid=$fbme[id]// )// "; /* //concatenation - all the movies that my friends like $query = " SELECT name, location FROM event WHERE strpos(name, \"KAZ\")>=0 AND eid IN ( SELECT eid FROM event_member WHERE uid=$fbme[id] ) "; $FQL = array ( "method" => "fql.query", "query" => $query); $datas = $facebook->api($FQL); if($datas[0]) foreach($datas as $data)

{ if(!is_array($data)) echo $data .$nl; else { $key = array_keys($datas[0],$data); echo $key[0] .$nl; foreach($data as $dt) { echo "...." . $dt .$nl; } } } out($datas); */ }catch (FacebookApiException $e) { echo '<pre>'; print_r($e); echo '</pre>'; }?>

</div> <!-- end canvas -->Hi,i did just as you said - 3 files1. header.php with the upper code2. fbstyle.css with the middle code3. index.php with the lower code

i changed the api, secret & url. i'm using Iframebut it show me nothing in the appany idea why?what about the <html>&<body> tags, i don't need them?