forked from blallo/rss-bridge
Merge pull request #150 from teromene/master
Ajout du support des journaux de profils
This commit is contained in:
commit
063ee612cf
1 changed files with 31 additions and 23 deletions
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* @name Facebook
|
* @name Facebook
|
||||||
* @homepage http://facebook.com/
|
* @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
|
* @update 03/08/2015
|
||||||
* @maintainer teromene
|
* @maintainer teromene
|
||||||
* @use1(u="username")
|
* @use1(u="username")
|
||||||
|
@ -16,8 +16,13 @@ class FacebookBridge extends BridgeAbstract{
|
||||||
$html = '';
|
$html = '';
|
||||||
|
|
||||||
if(isset($param['u'])) {
|
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 {
|
} else {
|
||||||
|
|
||||||
$this->returnError('You must specify a Facebook username.', 400);
|
$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);
|
$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
|
//Clean the content of the page
|
||||||
$content = preg_replace('/(?i)><div class=\"clearfix([^>]+)>(.+?)div\ class=\"userContent\"/i', "", $post);
|
$content = preg_replace('/(?i)><div class=\"clearfix([^>]+)>(.+?)div\ class=\"userContent\"/i', "", $post);
|
||||||
$content = preg_replace('/(?i)><div class=\"_59tj([^>]+)>(.+?)<\/div><\/div><a/i', "", $content);
|
$content = preg_replace('/(?i)><div class=\"_59tj([^>]+)>(.+?)<\/div><\/div><a/i', "", $content);
|
||||||
$content = preg_replace('/(?i)><div class=\"_3dp([^>]+)>(.+?)div\ class=\"[^u]+userContent\"/i', "", $content);
|
$content = preg_replace('/(?i)><div class=\"_3dp([^>]+)>(.+?)div\ class=\"[^u]+userContent\"/i', "", $content);
|
||||||
$content = preg_replace('/(?i)><div class=\"_4l5([^>]+)>(.+?)<\/div>/i', "", $content);
|
$content = preg_replace('/(?i)><div class=\"_4l5([^>]+)>(.+?)<\/div>/i', "", $content);
|
||||||
|
|
||||||
$content = strip_tags($content,"<a><img>");
|
$content = strip_tags($content,"<a><img>");
|
||||||
|
|
||||||
|
|
||||||
$date = $post->find("abbr")[0];
|
$date = $post->find("abbr")[0];
|
||||||
if(isset($date) && $date->hasAttribute("data-utime")) {
|
if(isset($date) && $date->hasAttribute("data-utime")) {
|
||||||
$date = $date->getAttribute("data-utime");
|
$date = $date->getAttribute("data-utime");
|
||||||
} else {
|
} else {
|
||||||
$date = 0;
|
$date = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$item->uri = 'https://facebook.com'.$post->find("abbr")[0]->parent()->getAttribute("href");
|
$item->uri = 'https://facebook.com'.str_replace("&", "&", $post->find("abbr")[0]->parent()->getAttribute("href"));
|
||||||
$item->content = $content;
|
|
||||||
$item->title = $param['u']." | ".strip_tags($content);
|
$item->content = $content;
|
||||||
$item->timestamp = $date;
|
$item->title = $param['u']." | ".strip_tags($content);
|
||||||
|
$item->timestamp = $date;
|
||||||
|
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
|
|
Loading…
Reference in a new issue