问题
Well, I really have no idea how to do this, all I see in some posts here is like
use this and you will get fan page id thing.
$signedrequest = $facebook->getSignedRequest();
And so on..
But my problem lies in here, I'm trying to do a mysql select query, for example
//Note that $uid is MY user id
$query = "SELECT fanpage_id FROM fb_table WHERE uid='".$uid."';
$result = mysql_query($query);
$fanpage_id = $result[0];
So if I echo the fan page id, it will output like this
420276361382765
How do I convert it to facebook fan page name using the PHP SDK?
Any help would be appreciated. Thanks.
回答1:
Using Graph API:
https://graph.facebook.com/**user_id**/likes?fields=name,created_time,id,likes,talking_about_count&access_token=**Your_Access_Token**
This is through FQL:
select page_id from page_fan where uid = me()
You need to have the following permissions:
user_likes permissions if querying the current user.
friends_likes permissions if querying a user's friend.
hope it helps.
回答2:
You Need user_likes permissions
'scope' => 'email,user_likes,friends_birthday',
$pages=$facebook->api("/me/likes");
$row=array();
foreach($pages['data'] as $row)
{
echo $row['category'] ;
echo '<br>';
echo $row['name'] ;
echo '<br>';
echo $row['id'] ;
echo '<br>';
echo $row['created_time'] ;
echo '<br>--------------------------------------------------------------';
echo'<br>';
}
Hope it Helps
来源:https://stackoverflow.com/questions/15043851/convert-facebook-fanpage-id-to-fanpage-name-php-sdk