diff --git a/api-samples/upload-api/get-info.php b/api-samples/upload-api/get-info.php index 4bbfa793..f3261954 100644 --- a/api-samples/upload-api/get-info.php +++ b/api-samples/upload-api/get-info.php @@ -4,4 +4,9 @@ $uploader = new Uploadcare\Uploader\Uploader($configuration); $fileInfo = $uploader->fromPath(__DIR__ . '/squirrel.jpg'); -echo \sprintf('URL: %s, ID: %s, Mime type: %s', $fileInfo->getUrl(), $fileInfo->getUuid(), $fileInfo->getMimeType()); +header('Content-Type: application/json; charset=utf-8'); +echo json_encode([ + 'url' => $fileInfo->getUrl(), + 'id' => $fileInfo->getUuid(), + 'mimeType' => $fileInfo->getMimeType(), +], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); diff --git a/api-samples/upload-api/post-base.php b/api-samples/upload-api/post-base.php index 6e3e464e..d436268a 100644 --- a/api-samples/upload-api/post-base.php +++ b/api-samples/upload-api/post-base.php @@ -7,7 +7,13 @@ 'pet' => 'cat', ]); -echo \sprintf("URL: %s, ID: %s, Mime type: %s\n", $fileInfo->getUrl(), $fileInfo->getUuid(), $fileInfo->getMimeType()); +$data = [ + 'url' => $fileInfo->getUrl(), + 'id' => $fileInfo->getUuid(), + 'mimeType' => $fileInfo->getMimeType(), +]; foreach ($fileInfo->getMetadata() as $key => $value) { - echo \sprintf("%s: %s\n", $key, $value); + $data[$key] = $value; } +header('Content-Type: application/json; charset=utf-8'); +echo json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);