From 221ac239e1e31e5066799a8e44bb6e2fb569f016 Mon Sep 17 00:00:00 2001 From: teromene Date: Mon, 31 Aug 2015 22:59:08 +0200 Subject: [PATCH 1/3] Ajout d'un bridge pour Facebook --- bridges/FacebookBridge.php | 79 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 bridges/FacebookBridge.php diff --git a/bridges/FacebookBridge.php b/bridges/FacebookBridge.php new file mode 100644 index 00000000..378ac76b --- /dev/null +++ b/bridges/FacebookBridge.php @@ -0,0 +1,79 @@ +returnError('No results for this query.', 404); + } else { + + $this->returnError('You must specify a Facebook username.', 400); + + } + + + + $element = $html->find("[id^=PagePostsSectionPagelet-]")[0]->children(0)->children(0); + + foreach($element->children() as $post) { + + $item = new \Item(); + + if($post->hasAttribute("data-time")) { + + //Clean the content of the page + $content = preg_replace('/(?i)>
]+)>(.+?)div\ class=\"userContent\"/i', "", $post); + $content = preg_replace('/(?i)>
]+)>(.+?)<\/div><\/div>
]+)>(.+?)div\ class=\"[^u]+userContent\"/i', "", $content); + $content = preg_replace('/(?i)>
]+)>(.+?)<\/div>/i', "", $content); + + $content = strip_tags($content,""); + + + $date = $post->find("abbr")[0]; + if(isset($date) && $date->hasAttribute("data-utime")) { + $date = $date->getAttribute("data-utime"); + } else { + $date = 0; + } + + $item->uri = 'https://facebook.com/'.urlencode($param['u']); + $item->content = $content; + $item->title = $param['u']." | ".strip_tags($content); + $item->timestamp = $date; + + $this->items[] = $item; + } + } + + + + } + + public function getName(){ + return 'Facebook Bridge'; + } + + public function getURI(){ + return 'http://facebook.com'; + } + + public function getCacheDuration(){ + return 01; // 5 minutes + } +} + +?> From 7680b065b52cc4bebdbc75cfd8a8dca1d1da7849 Mon Sep 17 00:00:00 2001 From: teromene Date: Mon, 31 Aug 2015 23:02:11 +0200 Subject: [PATCH 2/3] =?UTF-8?q?Modification=20de=20la=20dur=C3=A9e=20du=20?= =?UTF-8?q?cache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bridges/FacebookBridge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/FacebookBridge.php b/bridges/FacebookBridge.php index 378ac76b..d62ef4c7 100644 --- a/bridges/FacebookBridge.php +++ b/bridges/FacebookBridge.php @@ -72,7 +72,7 @@ class FacebookBridge extends BridgeAbstract{ } public function getCacheDuration(){ - return 01; // 5 minutes + return 300; // 5 minutes } } From 9dfa1d6f258beb3083955244499576b19d701f63 Mon Sep 17 00:00:00 2001 From: teromene Date: Tue, 1 Sep 2015 00:04:13 +0200 Subject: [PATCH 3/3] Ajout d'une URI par post --- bridges/FacebookBridge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/FacebookBridge.php b/bridges/FacebookBridge.php index d62ef4c7..a3fd5846 100644 --- a/bridges/FacebookBridge.php +++ b/bridges/FacebookBridge.php @@ -50,7 +50,7 @@ class FacebookBridge extends BridgeAbstract{ $date = 0; } - $item->uri = 'https://facebook.com/'.urlencode($param['u']); + $item->uri = 'https://facebook.com'.$post->find("abbr")[0]->parent()->getAttribute("href"); $item->content = $content; $item->title = $param['u']." | ".strip_tags($content); $item->timestamp = $date;