public newestMentionId ( ) : mixed | ||
return | mixed |
public function newestMentionId()
{
$client = initTwitter();
try {
$mentions = $client->get('statuses/mentions_timeline.json?count=1');
$mentions = json_decode($mentions->getBody(), true);
if (count($mentions)) {
return $mentions[0]['id_str'];
}
return false;
} catch (\GuzzleHttp\Exception\ClientException $e) {
getErrorMessage($e->getResponse()->getStatusCode());
return back();
}
}
/** * 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'); }