예제 #1
0
 /**
  *    Get tweets
  */
 public function get(Request $request)
 {
     $amount = $request->input('amount');
     $selector = $request->input('selector');
     $debug = $request->input('debug');
     # Get tweets log state
     $fresh = (bool) Log::recentByType('tweets', '0:02:00')->count();
     if (!$fresh) {
         $statuses = array();
         $timelines = array();
         $users = array();
         $tweets = array();
         $images = array();
         $streams = array();
         $twitter_statuses = env('TWITTER_STATUSES');
         // Get statuses
         $this->getStatuses($statuses, $twitter_statuses);
         // Get timelines
         $this->getTimelines($statuses, $twitter_statuses);
         // Parse statuses
         $this->parseStatuses($statuses, $users, $tweets, $images, $streams, $twitter_statuses, $amount);
         // Add to DB
         $this->addToDB($users, $tweets, $images, $streams, $debug);
         Log::updateLog('tweets');
         // Delete older
         //$oldTweets = Tweet::olderTweets()->get();
         //Image::olderByTypes(array('twitter'), 100)->delete();
     }
     // Filter tweets
     return $this->filterTweets($amount, $selector);
 }
예제 #2
0
 /**
  *    Get/Update images
  */
 public function get(Request $request)
 {
     $amount = $request->input('amount');
     $selector = $request->input('selector');
     # Get images log state
     $fresh = (bool) Log::recentByType('images', '0:12:00')->count();
     if ($fresh) {
         $collect = array();
         // Get images from Dropbox
         $squared = $this->getSquared($collect);
         $dropbox = $this->getDropbox($collect);
         // Store and save them
         $this->storeAndSave($collect);
     }
     Log::updateLog('dropbox');
     $fields = array('tid', 'content');
     $squared = Dbox::getSquared($fields, $amount)->get();
     $content = $this->parseSquared($squared);
     shuffle($content);
     return response()->json(['contents' => $content, 'selector' => $selector]);
 }