From c6ec5c45d154c7df16dc6006ce319e68c5d2a86f Mon Sep 17 00:00:00 2001 From: pauder Date: Tue, 29 Oct 2013 09:26:48 +0100 Subject: [PATCH] Add Instagram bridge --- bridges/InstagramBridge.php | 56 +++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 bridges/InstagramBridge.php diff --git a/bridges/InstagramBridge.php b/bridges/InstagramBridge.php new file mode 100644 index 0000000..dfe6e85 --- /dev/null +++ b/bridges/InstagramBridge.php @@ -0,0 +1,56 @@ +request = $param['u']; + $text = file_get_contents('http://instagram.com/'.urlencode($this->request)) or $this->returnError('Could not request Instagram.', 404); + } + else { + $this->returnError('You must specify a Instagram username (?u=...).', 400); + } + + + // "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)) + { + foreach($matches[0] as $key => $dummy) + { + $imageurl = stripslashes($matches[1][$key]); + $width = (int) $matches[2][$key]; + $height = (int) $matches[3][$key]; + + + $item = new \Item(); + $item->uri = $imageurl; + $item->content = ''; + $item->title = basename($imageurl); + $this->items[] = $item; + } + } + } + + public function getName(){ + return (!empty($this->request) ? $this->request .' - ' : '') .'Instagram Bridge'; + } + + public function getURI(){ + return 'http://instagram.com/'; + } + + public function getCacheDuration(){ + return 21600; // 6 hours + } +}