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!
-
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 Answers
Just look in the source code of the fb page and search for page_id. Voila!

- 555
- 2
- 6
- 16
-
2It'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
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.
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.

- 34,399
- 18
- 41
- 57

- 119
- 1
- 1
-
In my case the ID was 11 numeric digits. It's NOT the alphanumeric one that starts with `Prod...`. – Simon East Jan 12 '23 at 06:55
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://[^\"]+"

- 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
Only solution what worked for me.
Paste desired facebook URL in input
field and it will print Page ID.
https://www.duplichecker.com/find-facebook-id.php
hope this will help.

- 2,349
- 4
- 19
- 36
Just use https://graph.facebook.com/your_username and after you can see all the detain and your ID

- 642
- 8
- 11
-
2This no longer works. I get OAuth exceptions for both usernames and pages. – Dan Dascalescu Jul 01 '15 at 08:49
-
@DanDascalescu, what do you do now? I'm trying to find a fix for an app. – craned Oct 26 '15 at 23:47
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

- 37
- 3
Try This :
$url="http://graph.facebook.com/cocacola";
$content=file_get_contents($url);
$x=json_decode($content);
echo $x->id;

- 2,466
- 5
- 33
- 52
-
2This no longer works. I get OAuth exceptions for both usernames and pages. – Dan Dascalescu Jul 01 '15 at 08:49
-
-
1I have. That's why I said that it "*no longer* works". It's unfortunate, but one must resort to other methods. – Dan Dascalescu Jul 01 '15 at 09:40
-
ok, then post it as answer dude, its old answer and I'm unable to delete it – Mohit Bumb Jul 01 '15 at 10:00