From d6693f43465615e244d055f80e9ed3a1e264eec9 Mon Sep 17 00:00:00 2001 From: pauder Date: Thu, 30 Jan 2014 11:55:39 +0100 Subject: [PATCH] Fix bug because of a modification of instagram source page json content --- bridges/InstagramBridge.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/bridges/InstagramBridge.php b/bridges/InstagramBridge.php index 362add9e..ce91b0f1 100644 --- a/bridges/InstagramBridge.php +++ b/bridges/InstagramBridge.php @@ -29,31 +29,28 @@ class InstagramBridge extends BridgeAbstract{ continue; } - $pos = strpos($script->innertext, 'window._jscalls'); - if (false === $pos) + $pos = strpos(trim($script->innertext), 'window._sharedData'); + if (0 !== $pos) { continue; } $innertext = $script->innertext; - break; } - $json = trim(substr($innertext, $pos+15), ' =;'); - $pos = strpos($json, '}]],'); - $json = substr($json, $pos+4, -4); + + $json = trim(substr($innertext, $pos+18), ' =;'); $data = json_decode($json); - - $userMedia = $data[2][0]->props->userMedia; + + $userMedia = $data->entry_data->UserProfile[0]->userMedia; foreach($userMedia as $media) { $image = $media->images->standard_resolution; - - + $item = new \Item(); $item->uri = $media->link; $item->content = '';