/**
  * Initiate the service and copy new posts to our database
  */
 public function process()
 {
     $this->fbService = new FBPageFeedService();
     $storedPosts = $this->fbService->getStoredPosts();
     $posts = $this->fbService->getPostsFromFacebook();
     $inserted = 0;
     foreach ($posts as $i => $post) {
         if (!isset($post['FBID'])) {
             break;
         }
         $existingPost = FacebookPost::get()->filter('URL', $post['URL'])->first();
         if ($existingPost) {
             break;
         } else {
             if (isset($post['source'])) {
                 $imageSource = $post['source'];
             } else {
                 $imageSource = null;
             }
             $this->fbService->storePost($post['FBID'], $post['Content'], $post['URL'], $post['TimePosted'], $imageSource);
             $inserted++;
         }
     }
     echo 'Stored ' . $inserted . ' new posts.';
 }
 /**
  * Get our local copies of the Facebook Page posts
  *
  * @param int $limit
  * @return \DataList|\SS_Limitable
  */
 public function getStoredPosts($limit = 4)
 {
     return FacebookPost::get()->limit($limit);
 }