diff options
-rw-r--r-- | providers/Facebook.php | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/providers/Facebook.php b/providers/Facebook.php index 5eb0181..4f4c76e 100644 --- a/providers/Facebook.php +++ b/providers/Facebook.php @@ -33,33 +33,36 @@ class Facebook extends \Providers\HtmlFeed { print($tree->html()); } foreach ($tree->find('article') as $header) { - $data = json_decode($header->attr()['data-store'], TRUE)['linkdata']; - $data = json_decode(explode('page_insights.', $data)[1], TRUE); - $data = array_filter( - $data, - function($a) { return isset($a['post_context']); } - ); - $data = array_pop($data); - $data = $data['post_context']; - $key = ((array)($data['story_fbid']))[0]; - $texts = []; - foreach ($header->find('p, h3') as $paragraph) { - $texts[] = utf8_decode($paragraph->text()); - } - if (isset($this->_options['dump'])) { - print_r($data); - print($key); - print(PHP_EOL); - print_r($texts); - print(PHP_EOL); - } - if (count($texts)) { - $items[$key] = [ - 'id' => $key, - 'time' => $data['publish_time'], - 'content' => $header->html(), - 'texts' => $texts - ]; + $data = json_decode($header->attr()['data-store'], TRUE); + if (isset($data['linkdata'])) { + $data = $data['linkdata']; + $data = json_decode(explode('page_insights.', $data)[1], TRUE); + $data = array_filter( + $data, + function($a) { return isset($a['post_context']); } + ); + $data = array_pop($data); + $data = $data['post_context']; + $key = ((array)($data['story_fbid']))[0]; + $texts = []; + foreach ($header->find('p, h3') as $paragraph) { + $texts[] = utf8_decode($paragraph->text()); + } + if (isset($this->_options['dump'])) { + print_r($data); + print($key); + print(PHP_EOL); + print_r($texts); + print(PHP_EOL); + } + if (count($texts)) { + $items[$key] = [ + 'id' => $key, + 'time' => $data['publish_time'], + 'content' => $header->html(), + 'texts' => $texts + ]; + } } } if (isset($this->_options['dump'])) { |