public static function userLike($pageId, $userId)
 {
     try {
         $facebook = FacebookService::getFacebook();
         $data = $facebook->api('' . $pageId . '/members/' . $userId . '');
         if (array_key_exists('0', $data['data'])) {
             if (count($data['data'][0]) == 2) {
                 return true;
             }
         }
         return false;
     } catch (FacebookApiException $e) {
         $log = LogsService::getInstance($e);
         $log->fromArray(array('user_id' => $userId, 'type' => 'Like Error', 'message' => 'problem with checking whether the user likes page'));
         $log->save();
         return false;
     }
 }
 private function _saveUserData($facebook, $me)
 {
     $existingUser = Doctrine_Core::getTable('users')->findOneById($me['id']);
     $this->getContext()->set('userFromBase', $existingUser);
     if (!$existingUser) {
         $friends = json_encode(FacebookService::getUserFriends());
         $userData = array('id' => $me['id'], 'first_name' => $me['first_name'], 'last_name' => $me['last_name'], 'sex' => $me['gender'], 'friends' => $friends);
         $newUser = new Users();
         $newUser->fromArray($userData);
         $newUser->save();
         $this->getContext()->set('userFromBase', $newUser);
     }
 }