From ee4d4d9603be01c6396b189cb8652c7a37f278db Mon Sep 17 00:00:00 2001 From: teromene Date: Wed, 2 Sep 2015 13:49:36 +0200 Subject: [PATCH] Ajout du support des journaux de profils --- bridges/FacebookBridge.php | 54 ++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/bridges/FacebookBridge.php b/bridges/FacebookBridge.php index a3fd584..351dc39 100644 --- a/bridges/FacebookBridge.php +++ b/bridges/FacebookBridge.php @@ -3,7 +3,7 @@ * * @name Facebook * @homepage http://facebook.com/ -* @description Facebook bridge +* @description Input a page title or a profile log. For a profile log, please insert the parameter as follow : myExamplePage/132621766841117 * @update 03/08/2015 * @maintainer teromene * @use1(u="username") @@ -16,8 +16,13 @@ class FacebookBridge extends BridgeAbstract{ $html = ''; if(isset($param['u'])) { + if(!strpos($param['u'], "/")) { + $html = file_get_html('https://facebook.com/'.urlencode($param['u']).'?_fb_noscript=1') or $this->returnError('No results for this query.', 404); + } else { - $html = file_get_html('https://facebook.com/'.urlencode($param['u']).'?_fb_noscript=1') or $this->returnError('No results for this query.', 404); + $html = file_get_html('https://facebook.com/pages/'.$param['u'].'?_fb_noscript=1') or $this->returnError('No results for this query.', 404); + + } } else { $this->returnError('You must specify a Facebook username.', 400); @@ -28,39 +33,42 @@ class FacebookBridge extends BridgeAbstract{ $element = $html->find("[id^=PagePostsSectionPagelet-]")[0]->children(0)->children(0); - foreach($element->children() as $post) { + if(isset($element)) { + + foreach($element->children() as $post) { - $item = new \Item(); + $item = new \Item(); - if($post->hasAttribute("data-time")) { + if($post->hasAttribute("data-time")) { - //Clean the content of the page - $content = preg_replace('/(?i)>
]+)>(.+?)div\ class=\"userContent\"/i', "", $post); - $content = preg_replace('/(?i)>