How to get page_id from facebook url

My question is: how to get facebook page_id starting with a simple fb url. For instance:

Actually, if the url matches the string "facebook.com/pages/", I call:

else I call:

This approach seems to work well, but it is really empirical and looks at the documentation. I do not see any offers.
What do you think about?

+6
source share
2 answers

I'm not quite sure what you are asking for, but I think you are saying that you are trying to get the page id, which you only know by its “vanity url” or “nickname”.

Basically, you can execute the api facebook graph api request on the “vanity url” and then grab the id from the provided request.

For example ... if you open the Facebook charting API the https://developers.facebook.com/tools/explorer?method=GET&path=coca.cola API.

or request http://graph.facebook.com/coca.cola

you can see in the answer that you get "id": "40796308305" which is the identifier of the page you are talking about.

Going to http://www.facebook.com/40796308305 should confirm this.

Hope this helps.

+3
source

For my OG meta <meta property="fb:app_id" content="010101010101010" />

I got the page id of the page by going here:

https://developers.facebook.com/docs/plugins/page-plugin

get code> appId

Line 6: js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.9&appId= 010101010101010";

The shared debugger now stops complaining https://developers.facebook.com/tools/debug/

0
source

Source: https://habr.com/ru/post/898535/


All Articles