check for subdomain in parse_url

avffplco

New Member
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:\[code\] $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;\[/code\]This works if \[code\]$author_url\[/code\] 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 \[code\]preg_match("/facebook/i",$author_url)\[/code\] Thanks!
 
Back
Top