Fix bug because of a modification of instagram source page json

content
This commit is contained in:
pauder 2014-01-30 11:55:39 +01:00
parent 3822e77561
commit d6693f4346

View file

@ -29,31 +29,28 @@ class InstagramBridge extends BridgeAbstract{
continue; continue;
} }
$pos = strpos($script->innertext, 'window._jscalls'); $pos = strpos(trim($script->innertext), 'window._sharedData');
if (false === $pos) if (0 !== $pos)
{ {
continue; continue;
} }
$innertext = $script->innertext; $innertext = $script->innertext;
break; break;
} }
$json = trim(substr($innertext, $pos+15), ' =;');
$pos = strpos($json, '}]],'); $json = trim(substr($innertext, $pos+18), ' =;');
$json = substr($json, $pos+4, -4);
$data = json_decode($json); $data = json_decode($json);
$userMedia = $data[2][0]->props->userMedia; $userMedia = $data->entry_data->UserProfile[0]->userMedia;
foreach($userMedia as $media) foreach($userMedia as $media)
{ {
$image = $media->images->standard_resolution; $image = $media->images->standard_resolution;
$item = new \Item(); $item = new \Item();
$item->uri = $media->link; $item->uri = $media->link;
$item->content = '<img src="' . htmlentities($image->url) . '" width="'.htmlentities($image->width).'" height="'.htmlentities($image->height).'" />'; $item->content = '<img src="' . htmlentities($image->url) . '" width="'.htmlentities($image->width).'" height="'.htmlentities($image->height).'" />';