Skip to content

Commit

Permalink
Update Facebook URL detection (#1334)
Browse files Browse the repository at this point in the history
* add detectParameters to FacebookBridge.php
  • Loading branch information
somini authored and teromene committed Oct 16, 2019
1 parent b0884e9 commit 0eab63d
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions bridges/FacebookBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,34 @@ public function getName(){
return parent::getName();
}

public function detectParameters($url){
$params = array();

// By profile
$regex = '/^(https?:\/\/)?(www\.)?facebook\.com\/profile\.php\?id\=([^\/?&\n]+)?(.*)/';
if(preg_match($regex, $url, $matches) > 0) {
$params['u'] = urldecode($matches[3]);
return $params;
}

// By group
$regex = '/^(https?:\/\/)?(www\.)?facebook\.com\/groups\/([^\/?\n]+)?(.*)/';
if(preg_match($regex, $url, $matches) > 0) {
$params['g'] = urldecode($matches[3]);
return $params;
}

// By username
$regex = '/^(https?:\/\/)?(www\.)?facebook\.com\/([^\/?\n]+)/';

if(preg_match($regex, $url, $matches) > 0) {
$params['u'] = urldecode($matches[3]);
return $params;
}

return null;
}

public function getURI() {
$uri = self::URI;

Expand Down

0 comments on commit 0eab63d

Please sign in to comment.