コード例 #1
0
ファイル: spider.php プロジェクト: neostoic/healthyfood
 public function updateVenue($system_venue_id, $cycles = 5)
 {
     $this->cliOutput('write', 'system_venue_id: ' . $system_venue_id);
     $InstagramClient = new \Instagram\Client();
     // switch($table) {
     // 	case 'venue':
     // first need to get the corresponding instagram place ID
     $instagram_venue_id = \Collection\Venue::getInstagramVenueId($system_venue_id);
     if (!$instagram_venue_id) {
         $foursquare_venue_id = \Collection\Venue::getFoursquareVenueId($system_venue_id);
         // get the ID via API
         $location = $InstagramClient->get('getLocation', $foursquare_venue_id);
         if (isset($location->data[0]->id) && $location->data[0]->id) {
             $instagram_venue_id = \Collection\Venue::saveInstagramVenueJsonToDB($location->data[0], $system_venue_id);
         }
         if (!$instagram_venue_id) {
             $this->cliOutput('write', 'no instagram_venue_id: ' . $system_venue_id);
             continue;
         }
     }
     // get pictures...
     $lastId = 0;
     $media = array();
     for ($i = 0; $i < $cycles; $i++) {
         $response = $InstagramClient->getMediaByLocation($instagram_venue_id, $lastId);
         if (!isset($response->data)) {
             break;
         }
         $media = array_merge($media, $response->data);
         if (!isset($response->pagination->next_max_id) || $lastId == $response->pagination->next_max_id) {
             break;
         }
         $lastId = $response->pagination->next_max_id;
     }
     $this->cliOutput('write', 'instagram_venue_id: ' . $instagram_venue_id);
     $this->cliOutput('write', 'pictures: ' . count($media));
     foreach ($media as $key => $media) {
         $response = \Collection\Interaction::saveInstagramJsonToDB($media, $system_venue_id);
     }
     return true;
 }
コード例 #2
0
ファイル: dashboard.php プロジェクト: neostoic/healthyfood
 /** 
  * @access  public
  * @return  Response
  */
 public function action_pictures()
 {
     $data = array();
     $data['Form'] = new \Form();
     $data['Input'] = new \Input();
     // $options = array();
     $options = \Input::get();
     $config = array('pagination_url' => \Input::uri() . '?' . http_build_query($options), 'total_items' => \Collection\Interaction::countSearchResults($options), 'uri_segment' => 'page', 'name' => 'bootstrap', 'per_page' => 50);
     $pagination = \Pagination::forge('venues', $config);
     $data['pagination'] = $pagination->render();
     // get venues
     $options['per_page'] = $pagination->per_page;
     $options['offset'] = $pagination->offset;
     $data['pictures'] = \Collection\Interaction::search($options);
     // get all regions
     $options = array();
     $data['regions'] = \Collection\Region::search($options);
     $data['order_by'] = \Form::select('order_by', \Input::get('order_by'), array('time_created' => 'Date', 'likes' => 'Likes', 'comments' => 'Comments'), array('style' => 'width: 80px'));
     $data['order_dir'] = \Form::select('order_dir', \Input::get('order_dir'), array('desc' => 'Desc', 'asc' => 'Asc'), array('style' => 'width: 80px'));
     $data['date_range'] = \Form::select('filter[date_range]', \Input::get('filter.date_range'), array('today' => 'Today', 'yesterday' => 'Yesterday', 'last2days' => 'Last 2 days ago', '2days' => '2 days ago', '3days' => '3 days ago', 'thisweek' => 'This week', 'thismonth' => 'This month'), array('style' => 'width: 80px'));
     $view = \View::forge('dashboard/pictures.twig', $data);
     return \Response::forge($view);
 }
コード例 #3
0
ファイル: api.php プロジェクト: neostoic/healthyfood
 public function get_pictures()
 {
     header('Access-Control-Allow-Origin: *');
     $options = array();
     $options['order_by'] = 'likes';
     $options['order_dir'] = 'desc';
     $options['filter'] = array();
     $options['filter']['date_range'] = 'thisweek';
     // get pics
     $options['per_page'] = 500;
     $options['offset'] = 0;
     $data['pictures'] = \Collection\Interaction::search($options);
     return $this->response($data);
 }