Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get Facebook page username or facebook page ID from url

I've made a website where users can submit their Facebook page and I orginally coded it assuming that they would of set up a vanity URL for their page. E.g.

http://www.facebook.com/myfacebookpage

But I forgot that some pages can have urls such as

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

My question is how do I use PHP to grab the part of the url in bold?

Thanks!

like image 858
Frank Avatar asked Dec 15 '22 10:12

Frank


1 Answers

You can just recode your application to use https://graph.facebook.com/?ids=

Which will take both

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

Examples

  • https://graph.facebook.com/?ids=https://www.facebook.com/boo
  • https://graph.facebook.com/?ids=https://www.facebook.com/pages/phwd/113702895386410
like image 169
phwd Avatar answered May 11 '23 13:05

phwd