How to get friend list in array on facebook fan page tab application?

Oct 02

How to get friend list in array on facebook fan page tab application?

Last two night I was struggling in finding the solution of  my question “How to get friend list in array on facebook fan page tab application?

Finally find the solution last night..Just follow the following

Enable a ajax call on first click on facebook fanpage application at the tab then in the post page of ajax
run this code combination of PHP and FQL

<?php
include 'facebook.php';
$facebook = new Facebook('APIKEY','APPSECRET');
$user=$_REQUEST['fb_sig_user'];
$query_page="SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = $user)";
$result_frnd = $facebook->api_client->fql_query($query_page);
if($result_frnd)
{
$i=0;
foreach ($result_frnd as $frnd)
{
$allFriend[$i]=$frnd['uid'];
$i++;
}
}

?>

All the friend’s user id will be stored in $allFriend[] array…
Enjoy

3 comments

  1. Thanks man im very happy cuz i find you

    but i have a problem

    i want to use this code in button
    example

    when i click in this button i want to show the first user
    $allFriend[0]
    $i++
    click again
    $allFriend[2]

    ——————-

    like button Next …

Leave a Reply