Convert Facebook Fanpage ID to Fanpage Name PHP SDK

给你一囗甜甜゛ 提交于 2019-12-11 15:04:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!