public function newestPostId() { $fb = initFb(); $token = $this->config->FbAccessToken(); try { $posts = $fb->get('/' . config('crm-launcher.facebook_credentials.facebook_page_id') . '/tagged?fields=from,message,created_time,full_picture&limit=1', $token); $posts = json_decode($posts->getBody()); if (count($posts->data)) { return $posts->data[0]->id; } return false; } catch (Exception $e) { getErrorMessage($e->getCode()); 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'); }