Get Facebook fan page ID

前端 未结 9 1684
名媛妹妹
名媛妹妹 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 "<br />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/

    0 讨论(0)
  • 2021-02-04 09:27

    The URL to the fan page will have the ID in it. For example, the Stack Overflow fan page

    http://www.facebook.com/pages/Stack-Overflow/105665906133609

    The ID is 105665906133609

    Some pages have aliases, which are also usable as the ID. For example, the Marine Corps' fan page is

    http://www.facebook.com/marinecorps

    So the ID is marinecorps

    Alternatively, you can use the generator on the documentation page as well.

    0 讨论(0)
  • 2021-02-04 09:29

    You can replace www to graph in the page URL. For example id of the Coca-Cola page http://graph.facebook.com/cocacola (first value).

    0 讨论(0)
提交回复
热议问题