From 40f6e51b067bbe1f3761906f2a747e8cc8448de2 Mon Sep 17 00:00:00 2001 From: pauder Date: Tue, 29 Oct 2013 10:40:31 +0100 Subject: [PATCH] add date --- bridges/InstagramBridge.php | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/bridges/InstagramBridge.php b/bridges/InstagramBridge.php index dfe6e857..3adc71b9 100644 --- a/bridges/InstagramBridge.php +++ b/bridges/InstagramBridge.php @@ -21,22 +21,36 @@ class InstagramBridge extends BridgeAbstract{ $this->returnError('You must specify a Instagram username (?u=...).', 400); } + + + $image = '"(\w+)":\{"url":"(http:[^"]+)","width":(\d+),"height":(\d+)\}'; - // "standard_resolution":{"url":"http:\/\/distilleryimage6.s3.amazonaws.com\/5ff1829036bc11e3b6c622000a1f92d1_7.jpg","width":612,"height":612} - - if (preg_match_all('/"standard_resolution":\{"url":"(http:[^"]+)","width":(\d+),"height":(\d+)\}/', $text, $matches)) + if (preg_match_all('/"created_time":"(\d+)"\s*,\s*"images":\{'.$image.','.$image.','.$image.'\}/', $text, $matches)) { foreach($matches[0] as $key => $dummy) { - $imageurl = stripslashes($matches[1][$key]); - $width = (int) $matches[2][$key]; - $height = (int) $matches[3][$key]; + $timestamp = (int) $matches[1][$key]; + $images = array(); + + $pos = 2; + for($i = 0; $i < 3; $i++) + { + $imagetype = $matches[$pos++][$key]; + + $images[$imagetype] = array( + 'url' => stripslashes($matches[$pos++][$key]), + 'width' => (int) $matches[$pos++][$key], + 'height' => (int) $matches[$pos++][$key] + ); + + } $item = new \Item(); - $item->uri = $imageurl; - $item->content = ''; - $item->title = basename($imageurl); + $item->uri = $images['standard_resolution']['url']; + $item->content = ''; + $item->title = basename($images['standard_resolution']['url']); + $item->timestamp = $timestamp; $this->items[] = $item; } }