/** * Execute the console command. * * @return mixed */ public function handle() { if (isFacebookLinked()) { $this->update->collectPrivateConversations(); $this->update->collectPosts(); } if (isTwitterLinked()) { $this->update->collectMentions(); $this->update->collectDirectMessages(); } $this->log->updateLog('fetching'); }
/** * Get most recent id's for Twitter & Facebook * * @return void */ private function initIds() { $message = new Message(); if (isTwitterLinked()) { $mentionId = $this->twitterContent->newestMentionId(); $directId = $this->twitterContent->newestDirectId(); if ($mentionId) { $message->tweet_id = $mentionId; } if ($directId) { $message->direct_id = $directId; } } if (isFacebookLinked()) { $postId = $this->facebookContent->newestPostId(); $conversationId = $this->facebookContent->newestConversationId(); if ($postId) { $message->fb_post_id = $postId; } if ($conversationId) { $message->fb_private_id = $conversationId; } } $message->post_date = Carbon::now(); $message->save(); $this->log->updateLog('fetching'); }
/** * Check seconds between previous API call & now * @return int */ public function secondsago($type) { if (Log::where('case_type', $type)->exists()) { $now = Carbon::now(); $last = Log::LatestLog($type); $lastLog = new Carbon($last); return $now->diffInSeconds($lastLog); } return false; }