/** * 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); }
/** * Updates the emergency text */ public function post(Request $request) { $json = json_encode(array('input' => $request->input('input'), 'state' => $request->input('state'))); if (Log::updateLogEmergency('emergency', $json)) { return response()->json(['contents' => json_decode(Log::getEmergency()->get()->first()['json'])]); } }
/** * 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]); }
/** * 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:05:00')->count(); # If it's time to fetch more and add to the DB if (!$fresh) { $collect = array(); $streams = array(); $users = array(); // Request Instagram API $this->getFromInstagram('instagram', $collect, $streams, $users); // Request Instagram API (tagged) $this->getFromInstagram('instatag', $collect, $streams, $users); // Insert results in DB $this->addToDB($collect, $streams, $users); // Update log reference //Log::updateLog('images'); // Clean old entries $this->cleanOldEntries(); } return $this->getRecentImages($amount, $selector); }