public function lookup($id) { $instagram = new Instagram\Instagram(); $instagram->setClientID(\Yii::$app->params['instagram']['client_id']); $media = $instagram->getMedia($id); return $media; }
private function getSocialHashtag($tag) { $socialHashtag = new SocialHashtag($tag); $instagram = new Instagram(); $instagram->setClientID(INSTAGRAM_CLIENT_ID); $socialHashtag->addFeed(new InstagramFeed($instagram, new InstagramDataFormatter())); return $socialHashtag; }
public function searchInstagram() { $instagram = new Instagram\Instagram(); $instagram->setClientID(\Yii::$app->params['instagram']['client_id']); $end_at = $this->start_at + $this->duration * 60; $params = array('min_timestamp' => $this->start_at, 'max_timestamp' => $end_at, 'distance' => $this->distance, 'count' => 50); $media = $instagram->searchMedia($this->latitude, $this->longitude, $params); foreach ($media as $m) { if (isset($m->caption->text)) { $caption = $m->caption->text; } else { $caption = ''; } $i = new Gram(); $i->add($this->id, $m->user->username, $m->link, $m->created_time, $m->images->thumbnail->url, $caption); } }
public function onRun() { $key = $this->makeKey(); if (Cache::has($key)) { $this->media = $this->page['media'] = Cache::get($key); } else { $settings = Settings::instance(); $api = new Instagram(); $api->setClientID($settings->client_id); if ($settings->access_token) { $api->setAccessToken($settings->access_token); } $this->media = $this->page['media'] = $api->getTagMedia($this->property('tag'), array('count' => $this->property('limit', 10))); $expires_at = Carbon::now()->addMinutes($this->property('cache')); Cache::put($key, $this->media, $expires_at); } }
public function onRun() { $key = $this->makeKey(); if (Cache::has($key)) { $this->single = $this->page['single'] = Cache::get($key); } else { $settings = Settings::instance(); $api = new Instagram(); $api->setClientID($settings->client_id); if ($settings->access_token) { $api->setAccessToken($settings->access_token); } // Get the shortcode from the url $parts = explode('/p/', $this->property('url')); $parts = explode('/', $parts[1]); $shortcode = $parts[0]; // Now get the media info $this->single = $this->page['single'] = $api->getMediaByShortcode($shortcode); // Cache it $expires_at = Carbon::now()->addMinutes($this->property('cache')); Cache::put($key, $this->single, $expires_at); } }