[Pinterest] Add implementation for user/board

The data is no longer provided in HTML upon request,
but rather encoded as JSON in a SCRIPT section and
decoded via Javascript on the client side. The bridge
now decodes the data and returns valid feeds again.
This commit is contained in:
logmanoriginal 2016-09-17 20:10:00 +02:00
parent f8e0a4afbc
commit c3a1cbe98a

View file

@ -68,6 +68,28 @@ class PinterestBridge extends BridgeAbstract {
. $item['fullname'];
$item['title'] = $img->getAttribute('alt');
$this->items[] = $item;
}
} elseif($this->queriedContext === 'By username and board'){
$container = $html->find('SCRIPT[type="application/ld+json"]', 0)
or $this->returnServerError('Unable to find data container!');
$json = json_decode($container->innertext, true);
foreach($json['itemListElement'] as $element){
$item = array();
$item['uri'] = $element['item']['sharedContent']['author']['url'];
$item['title'] = $element['item']['name'];
$item['author'] = $element['item']['user']['name'];
$item['timestamp'] = strtotime($element['item']['datePublished']);
$item['content'] = <<<EOD
<a href="{$item['uri']}">
<img src="{$element['item']['image']}">
</a>
<p>{$element['item']['text']}</p>
EOD;
$this->items[] = $item;
}
}