How to get facebook page name or facebook page id from url

I created a website where users can post their page on Facebook, and I naturally encoded it, assuming they set the vanity URL for their page. For instance.

http://www.facebook.com/ myfacebookpage

But I forgot that some pages might have URLs like

http://www.facebook.com/pages/myfacebookpage/ 54878424154545487

My question is how to use PHP to capture part of the URL in bold ?

Thanks!

+4
source share
2 answers

like this:

$url='http://www.facebook.com/pages/myfacebookpage/54878424154545487'; // the input $pieces = explode('/', $url); // divides the string in pieces where '/' is found $key=end($pieces); //takes the last piece 
+5
source

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


All Articles