_options['force'])) {
$this->_cacheTimeout = '1 second';
}
}
protected function _getCachePath() {
return '../cache/facebook.%s';
}
protected function _fetchItems() {
$jsonContent = [];
exec('direnv exec ' .
implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), '..', 'bin', 'fb-scrape']) . ' ' .
'python ' . implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), '..', 'bin', 'fb-scrape', 'get-fb-content.py']) . ' ' .
escapeshellarg($this->_feed), $jsonContent);
return json_decode(implode(PHP_EOL, $jsonContent), TRUE);
}
protected function _mapItems($content) {
return array_map(
function ($obj) {
$texts = $obj['texts'];
if (!count($texts)) {
$texts[] = '';
}
if ($obj['images']) {
$texts = array_merge(
$texts,
array_map(function($i) {
return sprintf('
', $i);
}, $obj['images'])
);
}
$item = new Item();
$item->ID = $obj['id'];
$item->Link = sprintf(
'https://facebook.com/%s',
$obj['id']
);
$item->Title = $texts[0];
$item->Text = implode('
', $texts);
$item->Time = $obj['time'];
return $item;
},
$content
);
}
protected function _sortContent($content) {
return $content;
}
protected function _spamFilter($items) {
return $items;
}
public function title() {
return sprintf("%s's Facebook page posts", $this->_feed);
}
}
?>