Exemplo n.º 1
0
 protected function parse_response($raw, $mode)
 {
     if ($mode == 'fb_json') {
         $response = OAuthHelper::parse_json($raw);
         if (isset($response['data'])) {
             $data = $response['data'];
             unset($response);
         } else {
             $data =& $response;
         }
         foreach (array_keys($data) as $key) {
             if (!is_array($data[$key])) {
                 continue;
             }
             $type = false;
             $has = array();
             //album
             if (strpos($data[$key]['link'], 'album.php') !== false) {
                 $type = 'album';
                 $has = array('photos' => 'photo', 'comments' => 'comment');
             } else {
                 if (isset($data[$key]['start_time']) and isset($data[$key]['venue'])) {
                     $type = 'event';
                     $has = array('feed' => 'post', 'picture' => 'picture', 'noreply' => 'user', 'maybe' => 'user', 'invited' => 'user', 'attending' => 'user', 'declined' => 'user');
                 } else {
                     if (isset($data[$key]['venue'])) {
                         $type = 'group';
                         $has = array('feed' => 'post', 'members' => 'user', 'picture' => 'picture');
                     } else {
                         if (isset($data[$key]['to']) and isset($data[$key]['message'])) {
                             $type = 'message';
                             $has = array('comments' => 'comment');
                         } else {
                             if (isset($data[$key]['subject']) and isset($data[$key]['message'])) {
                                 $type = 'note';
                                 $has = array('comments' => 'comment');
                             } else {
                                 if (isset($data[$key]['category'])) {
                                     $type = 'page';
                                     $has = array('feed' => 'post', 'picture' => 'picture', 'tagged' => 'post', 'links' => 'post', 'photos' => 'photo', 'groups' => 'group', 'albums' => 'album', 'statuses' => 'post', 'videos' => 'video', 'notes' => 'note', 'posts' => 'post', 'events' => 'event');
                                 } else {
                                     if (isset($data[$key]['picture'])) {
                                         $type = 'photo';
                                         $has = array('comments' => 'comment');
                                     } else {
                                         if (isset($data[$key]['first_name']) and isset($data[$key]['last_name'])) {
                                             $type = 'user';
                                             $has = array('home' => 'post', 'feed' => 'post', 'tagged' => 'post', 'posts' => 'post', 'picture' => 'picture', 'friends' => 'user', 'activities' => 'page', 'interests' => 'page', 'music' => 'page', 'books' => 'page', 'movies' => 'page', 'television' => 'page', 'likes' => 'page', 'photos' => 'photo', 'albums' => 'album', 'videos' => 'video', 'groups' => 'group', 'statuses' => 'post', 'links' => 'post', 'notes' => 'note', 'events' => 'event', 'inbox' => 'message', 'outbox' => 'message', 'updates' => 'message');
                                         } else {
                                             if (isset($data[$key]['length'])) {
                                                 $type = 'video';
                                                 $has = array('comments' => 'comment');
                                             } else {
                                                 if (isset($data[$key]['from'])) {
                                                     //maybe a post
                                                     $type = 'post';
                                                     $has = array('comments' => 'comment');
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         return $data;
     } else {
         return parent::parse_response($raw, $mode);
     }
 }