[PHP] Facebook – 取得使用者基本資料的FQL


    include('facebook.php'); //引用API 
$facebook = new Facebook(array( 
'appId' => 'API編號', 
'secret' => '密碼'
)); 
    
    
    //FQL取得資料表user的欄位可以參考facebook文件: https://developers.facebook.com/docs/reference/fql/user/ 
    
    
    $fb_id = $facebook->getUser(); 
    try{ 
$aFriendList = $facebook->api(array( 
'method' => 'fql.query', 
'query' => 'select uid, name, pic,birthday_date, profile_url
from user where uid in (select uid2 from friend where uid1 = '.$fb_id.')' )
); 
}
    catch (Exception $e) { 
echo $e;

    
    //each 出每一筆資料
    foreach ($aFriendList as $row) {
//print_r($row);

?>

<div style="background:#D58D62; border-radius:10px; padding:20px; float:left; width:100px; height:100px;">
<div class="FB_name">
<?=$row["name"]; ?>
</div>
<div>
<?=$row["email"]; ?>
</div>
<div><a target="_blank" href="<?=$row["profile_url"] ?>"><img src="<?=$row["pic"] ?>" ></a></div>
</div>
<?
}
    

發表迴響