summaryrefslogtreecommitdiff
path: root/bridges/FacebookBridge.php
diff options
context:
space:
mode:
Diffstat (limited to 'bridges/FacebookBridge.php')
-rw-r--r--bridges/FacebookBridge.php46
1 files changed, 40 insertions, 6 deletions
diff --git a/bridges/FacebookBridge.php b/bridges/FacebookBridge.php
index 08b3a38..5ce67f9 100644
--- a/bridges/FacebookBridge.php
+++ b/bridges/FacebookBridge.php
@@ -2,7 +2,7 @@
class FacebookBridge extends BridgeAbstract {
const MAINTAINER = 'teromene, logmanoriginal';
- const NAME = 'Facebook Bridge';
+ const NAME = 'Facebook Bridge | Main Site';
const URI = 'https://www.facebook.com/';
const CACHE_TIMEOUT = 300; // 5min
const DESCRIPTION = 'Input a page title or a profile log. For a profile log,
@@ -66,14 +66,13 @@ class FacebookBridge extends BridgeAbstract {
case 'User':
if(!empty($this->authorName)) {
- return isset($this->extraInfos['name']) ? $this->extraInfos['name'] : $this->authorName
- . ' - ' . static::NAME;
+ return isset($this->extraInfos['name']) ? $this->extraInfos['name'] : $this->authorName;
}
break;
case 'Group':
if(!empty($this->groupName)) {
- return $this->groupName . ' - ' . static::NAME;
+ return $this->groupName;
}
break;
@@ -82,6 +81,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;
@@ -674,8 +701,15 @@ EOD;
$uri = $post->find('abbr')[0]->parent()->getAttribute('href');
- if (false !== strpos($uri, '?')) {
- $uri = substr($uri, 0, strpos($uri, '?'));
+ // Extract fbid and patch link
+ if (strpos($uri, '?') !== false) {
+ $query = substr($uri, strpos($uri, '?') + 1);
+ parse_str($query, $query_params);
+ if (isset($query_params['story_fbid'])) {
+ $uri = self::URI . $query_params['story_fbid'];
+ } else {
+ $uri = substr($uri, 0, strpos($uri, '?'));
+ }
}
//Build and add final item