Rubenwouters\CrmLauncher\Updates\UpdateAllCases::collectPosts PHP Метод

collectPosts() публичный Метод

Gets all posts on Facebook
public collectPosts ( ) : view
Результат view
    public function collectPosts()
    {
        $newestPost = $this->message->getNewestPostDate();
        $posts = $this->facebookContent->fetchPosts($newestPost);
        foreach ($posts->data as $key => $post) {
            $contact = $this->contact->createContact('facebook', $post);
            $case = $this->case->createCase('facebook_post', $post, $contact);
            $message = new Message();
            $message->contact_id = $contact->id;
            $message->fb_post_id = $post->id;
            $message->case_id = $case->id;
            if (isset($post->message)) {
                $message->message = $post->message;
            }
            $message->post_date = changeFbDateFormat($post->created_time);
            $message->save();
            $this->media->handleMedia($message->id, $post, 'facebook');
        }
        $newestComment = latestCommentDate();
        $newestInnerComment = $this->innerComment->LatestInnerCommentDate();
        $this->fetchComments($newestComment);
        $this->fetchInnerComments($newestInnerComment);
    }

Usage Example

Пример #1
0
 /**
  * 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');
 }