Lets see how to get User’s Friend data.
Create 2 files:
- index.php
- friends_data.php
Please note that this is only the code, you need to include Facebook Api scripts and Apps information.
In index.php, use this code
[php]$colnams="
uid,
email,
proxied_email,
username,
name,
first_name,
last_name,
sex,
birthday,
birthday_date,
profile_url
";
$pgno="1";
$defaultresultrownum="5";
$lowerlimit=($pgno-1)*$defaultresultrownum;
$upperlimit=$defaultresultrownum;
$searchtbnam="user";
$wherequery = "WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=’$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 Friends<b><br>";
include "friends_data.php";
}[/php]
In friends_data.php, use this code
[php]echo "<table border=’1′ width=’100%’>";
echo "<tr>
<th>S.No.</th>
<th>FB UID</th>
<th>Email</th>
<th>Proxy Email</th>
<th>Username</th>
<th>FB Name</th>
<th>First Name</th>
<th>Last Name</th>
<th>Gender</th>
<th>Birthday</th>
<th>Birthday Date</th>
<th>Profile URL</th>
</tr>";
for($i=0; $i<$friends_count; $i++)
{
$sno=$i+1;
$friend_uid=$friends[$i][uid];
$friend_eml=$friends[$i][email];
$friend_proxyeml=$friends[$i][‘proxied_email’];
$friend_usrnam=$friends[$i][username];
$friend_name=$friends[$i][name];
$friend_frsnam=$friends[$i][first_name];
$friend_lstnam=$friends[$i][last_name];
$friend_gnd=$friends[$i][sex];
$friend_birthday=$friends[$i][birthday];
$friend_birthday_date=$friends[$i][birthday_date];
$friend_profile_url=$friends[$i][profile_url];
echo "<tr>
<td>$sno</td>
<td>$friend_uid</td>
<td>$friend_eml</td>
<td>$friend_proxyeml</td>
<td>$friend_usrnam</td>
<td>$friend_name</td>
<td>$friend_frsnam</td>
<td>$friend_lstnam</td>
<td>$friend_gnd</td>
<td>$friend_birthday</td>
<td>$friend_birthday_date</td>
<td>$friend_profile_url</td>
</tr>";
}
echo "</table>";[/php]