From 0eab63d728def33f5592da94266e923d386ce1e6 Mon Sep 17 00:00:00 2001 From: somini Date: Wed, 16 Oct 2019 20:32:30 +0100 Subject: [PATCH] Update Facebook URL detection (#1334) * add detectParameters to FacebookBridge.php --- bridges/FacebookBridge.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/bridges/FacebookBridge.php b/bridges/FacebookBridge.php index 08b3a38a..83f082a8 100644 --- a/bridges/FacebookBridge.php +++ b/bridges/FacebookBridge.php @@ -82,6 +82,34 @@ class FacebookBridge extends BridgeAbstract { 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;