Get Facebook fan page ID

前端 未结 9 1682
名媛妹妹
名媛妹妹 2021-02-04 08:32

I\'ve got the Facebook user ID of the user who created a given page. Now I need to get the page ID to display like box in my website.

Different users have their own Face

9条回答
  •  伪装坚强ぢ
    2021-02-04 09:25

    I am presuming that you are the user and you want the page id of a page that you are the admin of.

    To get the id is fairly straightforward.

    First, you need to get a list of all pages associated with the user id:

    $fanpages = $facebook->api('me/accounts?access_token='.$accessToken);

    You would then do a loop like:

    foreach ($fanpages['data'] as $fanpage)
    {
    echo "
    Fan Page Name: ".$fanpage['name'] . " ID: ".$fanpage['id']; }

    That would list all the pages associated with the id.

    For a full list of the elements of the $fanpage array, take a look here:

    https://developers.facebook.com/docs/reference/api/page/

提交回复
热议问题