/**
  * create FB connection...
  * @return Facebook\Facebook
  */
 protected static function get_connection()
 {
     if (!self::$connection) {
         self::$connection_config += array('app_id' => Config::inst()->get("SilverstripeFacebookConnector", "app_id"), 'app_secret' => Config::inst()->get("SilverstripeFacebookConnector", "app_secret"), 'default_graph_version' => 'v2.4');
         self::$connection = new Facebook\Facebook(self::$connection_config);
     }
     return self::$connection;
 }
 public function Fetch($verbose = false)
 {
     $count = 0;
     if ($this->FacebookPageID) {
         $items = SilverstripeFacebookConnector::get_feed($this->FacebookPageID);
         if ($items) {
             foreach ($items as $item) {
                 if (!FacebookFeed_Item::get()->filter(array("UID" => $item["id"]))->first()) {
                     $count++;
                     $message = "";
                     if (isset($item["message"])) {
                         $message = $item["message"];
                     } else {
                         if (isset($item["description"])) {
                             $message = $item["description"];
                         }
                     }
                     //Converts UTF-8 into ISO-8859-1 to solve special symbols issues
                     $message = iconv("UTF-8", "ISO-8859-1//TRANSLIT", $message);
                     $message = $this->stripUnsafe($message);
                     //Get status update time
                     $pubDate = strtotime(isset($item["created_time"]) ? $item["created_time"] : "today");
                     $convertedDate = gmdate($timeFormat = 'Y-m-d', $pubDate);
                     //Customize this to your liking
                     //Get link to update
                     //Store values in array
                     $obj = new FacebookFeed_Item();
                     $obj->UID = $item["id"];
                     $obj->Title = (string) (isset($item["name"]) ? $item["name"] : "");
                     $obj->Date = $convertedDate;
                     $obj->Author = (string) (isset($item["from"]["name"]) ? $item["from"]["name"] : "");
                     $obj->Link = (string) (isset($item["link"]) ? $item["link"] : "");
                     $obj->PictureLink = (string) (isset($item["full_picture"]) ? $item["full_picture"] : "");
                     $obj->Description = $message;
                     $obj->FacebookFeed_PageID = $this->ID;
                     $obj->write();
                 }
             }
         } else {
             if ($verbose) {
                 DB::alteration_message("ERROR: no data returned", "deleted");
             }
         }
         if ($count == 0 && $verbose) {
             DB::alteration_message("Nothing to add.");
         }
     } else {
         if ($verbose) {
             DB::alteration_message("ERROR: no Facebook Page ID provided", "deleted");
         }
     }
     if ($count && $verbose) {
         DB::alteration_message("Added {$count} items", "created");
     }
 }