include_once "inc/class.Answer.php"; include_once "inc/class.Curl.php"; include_once "inc/class.DAO.php"; include_once "inc/class.Images.php"; include_once "inc/class.Model.php"; include_once "inc/class.Photo.php"; include_once "inc/class.PhotosData.php"; include_once "inc/class.User.php"; include_once "inc/class.UsersPhotos.php"; // Actions if (isset($_GET['action'])) { switch ($_GET['action']) { case 'get_users': $answer = Model::getUsersData(); break; case 'get_users_photos': $answer = Model::getUsersPhotos(); break; case 'get_photos_data': $answer = Model::getPhotosData(); break; default: $data = Answer::error('Action not found'); $answer = $data->encode(); break; } } else { $data = Answer::error('Action not found'); $answer = $data->encode(); } echo $answer;
/** * Метод возвращает json с данными отдельной фотографии * * @return string - json с данными отдельной фотографии */ public static function getPhotosData() { // Общие данные фотографии $photosData = DAO::getPhotosData($_GET['media_id']); // Ошибка if ($photosData->meta->code == 400) { $answer = Answer::error($photosData->meta->error_message); } else { $comments = DAO::getComments($_GET['media_id']); $likes = DAO::getLikes($_GET['media_id']); $photo = new PhotosData($photosData->data, $comments->data, $likes->data); $answer = Answer::good($photo); } return $answer->encode(); }