Update Facebook URL detection (#1334)

* add detectParameters to FacebookBridge.php
This commit is contained in:
somini 2019-10-16 20:32:30 +01:00 committed by Lyra
parent b0884e9158
commit 0eab63d728

View file

@ -82,6 +82,34 @@ class FacebookBridge extends BridgeAbstract {
return parent::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() { public function getURI() {
$uri = self::URI; $uri = self::URI;