Skip to content

Commit 598aad1

Browse files
committed
Change some responses in api-samples to JSON
1 parent d215ae2 commit 598aad1

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

api-samples/upload-api/get-info.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@
44
$uploader = new Uploadcare\Uploader\Uploader($configuration);
55
$fileInfo = $uploader->fromPath(__DIR__ . '/squirrel.jpg');
66

7-
echo \sprintf('URL: %s, ID: %s, Mime type: %s', $fileInfo->getUrl(), $fileInfo->getUuid(), $fileInfo->getMimeType());
7+
header('Content-Type: application/json; charset=utf-8');
8+
echo json_encode([
9+
'url' => $fileInfo->getUrl(),
10+
'id' => $fileInfo->getUuid(),
11+
'mimeType' => $fileInfo->getMimeType(),
12+
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

api-samples/upload-api/post-base.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77
'pet' => 'cat',
88
]);
99

10-
echo \sprintf("URL: %s, ID: %s, Mime type: %s\n", $fileInfo->getUrl(), $fileInfo->getUuid(), $fileInfo->getMimeType());
10+
$data = [
11+
'url' => $fileInfo->getUrl(),
12+
'id' => $fileInfo->getUuid(),
13+
'mimeType' => $fileInfo->getMimeType(),
14+
];
1115
foreach ($fileInfo->getMetadata() as $key => $value) {
12-
echo \sprintf("%s: %s\n", $key, $value);
16+
$data[$key] = $value;
1317
}
18+
header('Content-Type: application/json; charset=utf-8');
19+
echo json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

0 commit comments

Comments
 (0)