Beispiel #1
0
 public function getFeed()
 {
     // Allocate a new cURL handle
     $ch = curl_init("https://graph.facebook.com/me/feed?access_token=" . Cookie::getItem("fb_token"));
     if (!$ch) {
         die("Cannot allocate a new PHP-CURL handle");
     }
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
     $data = curl_exec($ch);
     curl_close($ch);
     $data = json_decode($data);
     $posts = [];
     foreach ($data->data as $feed) {
         $post = new \stdClass();
         $feed = (array) $feed;
         if (isset($feed["message"])) {
             $post->title = $feed["message"];
         }
         if (isset($feed["story"])) {
             $post->title = $feed["story"];
         }
         $post->time = new \DateTime($feed["created_time"]);
         $post->via = "Facebook";
         $posts[] = $post;
     }
     return $posts;
 }