From c3a1cbe98a36dbb0229b0ef79270bc7e9f28d581 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Sat, 17 Sep 2016 20:10:00 +0200 Subject: [PATCH] [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. --- bridges/PinterestBridge.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/bridges/PinterestBridge.php b/bridges/PinterestBridge.php index 4907f40..59bbf12 100644 --- a/bridges/PinterestBridge.php +++ b/bridges/PinterestBridge.php @@ -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'] = << + + +

{$element['item']['text']}

+EOD; + $this->items[] = $item; } }