Hello, I am trying to write a function to just get the users profile id or username from Facebook. They enter there url into a form then I'm trying to figure out if it's a Facebook profile page or other page. The problem is that if they enter an app page or other page that has a subdomain I would like to ignore that request.
Right now I have:
$author_url = http://facebook.com/profile?id=12345;
if(preg_match("/facebook/i",$author_url)){
$parse_author_url = (parse_url($author_url));
$parse_author_url_q = $parse_author_url['query'];
if(preg_match('/id[=]([0-9]*)/', $parse_author_url_q, $match)){
$fb_id = "/".$match[1];}
else{ $fb_id = $parse_author_url['path'];
}
$grav_url= "http://graph.facebook.com".$fb_id."/picture?type=square";
}
echo $gav_url;
This works if $author_url
has "id=" then use that as the profile id if not then it must be a user name or page name so use that instead. I need to run one more check that if the url contains facebook but is a subdomain ignore it. I belive I can do that in the first preg_match preg_match("/facebook/i",$author_url)
Thanks!