Facebook Apps – Get User’s Friendlists

For your apps see User Friendlists and names.

Use these 2 files:

  • index.php
  • lists_data.php

For index.php,

[php]<?php
$colnams="
flid,
name
";

$pgno="1";
$defaultresultrownum="5";
$lowerlimit=($pgno-1)*$defaultresultrownum;
$upperlimit=$defaultresultrownum;

$searchtbnam="friendlist";
$wherequery = "WHERE owner=’$fbuid’";
//$wherequery = "";
$resultsort="name";
$resultsortorder="asc";
$orderby="ORDER BY $resultsort $resultsortorder";
//$limit="LIMIT $lowerlimit,$upperlimit";

$fql    =  "SELECT $colnams FROM $searchtbnam $wherequery $orderby $limit";
$param  =   array(
‘method’     => ‘fql.query’,
‘query’     => $fql,
‘callback’    => ”
);
$_friends   =   $facebook->api($param);

//$friends_already_using_count=count($_friends);
//d($_friends);
$friends = $_friends;
$friends_count=count($friends);
if($friends_count>’0′)
{
echo "<b>$friends_count Friend Lists<b><br>";
include "lists_data.php";
}
?>[/php]

For lists_data.php,

[php]<?php

echo "<table border=’1′ width=’100%’>";
echo "<tr>
<th>S.No.</th>
<th>FLID</th>
<th>FL Name</th>
</tr>";

for($i=0; $i<$friends_count; $i++)
{
$sno=$i+1;
$friend_listid=$friends[$i][flid];
$friend_listnam=$friends[$i][name];

echo "<tr>
<td>$sno</td>
<td>$friend_listid</td>
<td>$friend_listnam</td>
</tr>";

}
echo "</table>";
?>
[/php]

Leave a Comment