How do I get Facebook page username or facebook pa

2019-04-09 19:08发布

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!

2条回答
祖国的老花朵
3楼-- · 2019-04-09 19:49

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
查看更多
登录 后发表回答