Example #1
0
 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);
     }
 }
Example #2
0
 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);
     }
 }