diff --git a/bridges/InstagramBridge.php b/bridges/InstagramBridge.php new file mode 100644 index 00000000..dfe6e857 --- /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 + } +}