23

I need to fetch page id of a facebook page of a given URL in graph API. e.g this is the URL http://www.facebook.com/platform and I want to get the page id of this facebook page. I tried all the possible solution but failed. Please any one help me....Please... Thanx!

21rw
  • 1,016
  • 1
  • 12
  • 26
iOS Monster
  • 2,099
  • 1
  • 22
  • 49
  • You can follow the details steps as explained here - https://stackoverflow.com/a/76329303/12326605 to get the Page access token and Page id. – Arpit Jain Aug 06 '23 at 06:58

8 Answers8

10

Just look in the source code of the fb page and search for page_id. Voila!

  • 2
    It's a little different now - here is what I found now works: "profile_delegate_page_id":"102248448806892" – snoopyjc Apr 10 '22 at 16:02
  • And the corresponding URL for iPhone is now like fb://page?id=102248448806892 - note this does NOT work on Android or web! – snoopyjc Apr 10 '22 at 16:12
9

The answers given before Oct 27, 2015 no longer work, and the other answer given after that is not dynamic, but requires site scraping. This answer provides the necessary URLs.

1) Get your App-id and App-secret by choosing an existing app or creating a new one at this url:

https://developers.facebook.com/apps/

2) Get an access token by making a GET request to this url:

https://graph.facebook.com/oauth/access_token?client_id=" + APP_ID + "&client_secret=" + APP_SECRET + "&grant_type=client_credentials

3) To get the page-id of your fan page, you need the page-name. Go to your fan page on facebook and look at the url. It will have this form:

https://www.facebook.com/{fan-page-name}

Once you have that, make a GET request to this url:

https://graph.facebook.com/{fan-page-name}?access_token={access-token}

It will return a bunch of JSON. You're looking for the first "id" element. This is your page-id.

See my answer here.

Community
  • 1
  • 1
craned
  • 2,991
  • 2
  • 34
  • 38
8

On the page, Press for code source: "Ctrl+U" and search "page_id", on the second or third search, you will find a 16 digit page id.

Now open copy the link: facebook.com/<your-page-id> to verify your finding.

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57
Sidharth Rai
  • 119
  • 1
  • 1
7

The answers given before this one (Oct 27, 2015) no longer work.

What works right now is to go to the page or user's Facebook page, and grep the source for fb://page/\d+ or fb://profile/\d+.

Example:

https://www.facebook.com/idorecall/

contains

fb://page/1605841049661522

https://www.facebook.com/dandasco

contains

fb://profile/100002764094643

Try this on the command line:

curl -skA "Mozilla/5.0" https://www.facebook.com/idorecall/ | grep -oE "fb://[^\"]+"
Dan Dascalescu
  • 143,271
  • 52
  • 317
  • 404
  • Either I'm making the wrong call, `https://graph.facebook.com/{page-id}/feed`, or your approach isn't actually working. I'm also worried about its dependability. All I need is a public page's news feed, but I keep getting `Invalid OAuth access token` error. – craned Oct 27 '15 at 15:16
  • @craned: You might have been overthinking it. I've updated my answer with an example. – Dan Dascalescu Oct 28 '15 at 06:08
  • Thanks, but I don't want to site scrape. Not only that, but Java doesn't make it easy to do so. I posted a more dynamic answer. – craned Oct 28 '15 at 18:18
  • Yeah, it's ridiculous how complicated it is to fetch a URL or read a line from a file in Java, compared to, say, Perl. – Dan Dascalescu Oct 28 '15 at 23:31
6

Only solution what worked for me.

Paste desired facebook URL in input

enter image description here

field and it will print Page ID.

enter image description here

https://www.duplichecker.com/find-facebook-id.php

hope this will help.

Hattori Hanzō
  • 2,349
  • 4
  • 19
  • 36
3

Just use https://graph.facebook.com/your_username and after you can see all the detain and your ID

Romano401
  • 642
  • 8
  • 11
2

Just Go To https://developers.facebook.com/tools/explorer Type in the name of your page in the box and click submit and you will get your page id

0

Try This :

 $url="http://graph.facebook.com/cocacola";
    $content=file_get_contents($url);
    $x=json_decode($content);
    echo $x->id;
Mohit Bumb
  • 2,466
  • 5
  • 33
  • 52