Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Supported PHP Versions](https://img.shields.io/packagist/dependency-v/aspose/barcode-cloud-php/php)](https://packagist.org/packages/aspose/barcode-cloud-php)

- API version: 4.0
- Package version: 25.5.0
- Package version: 25.6.0
- Supported PHP versions: ">=8.0"

## SDK and API Version Compatibility:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
}
},
"scripts": {
"format": "php-cs-fixer fix index.php src/Aspose/ tests/ --config=php-cs-fixer.conf",
"format": "php-cs-fixer fix index.php src/Aspose/ tests/ snippets/ --config=php-cs-fixer.conf",
"lint": "phpstan analyse index.php src/ tests/ --level=3",
"test": "phpunit"
}
Expand Down
66 changes: 33 additions & 33 deletions snippets/ManualFetchToken.php
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
<?php

require 'vendor/autoload.php';
require 'vendor/autoload.php';

use GuzzleHttp\Client;
use GuzzleHttp\Client;

$clientId = 'Client Id from https://dashboard.aspose.cloud/applications';
$clientSecret = 'Client Secret from https://dashboard.aspose.cloud/applications';
$clientId = 'Client Id from https://dashboard.aspose.cloud/applications';
$clientSecret = 'Client Secret from https://dashboard.aspose.cloud/applications';

// Check the client_id is changed to not break GitHub CI pipeline
if (str_starts_with($clientId, "Client Id")) {
echo "clientId not configured. Skip this snippet test";
return;
}
// Check the client_id is changed to not break GitHub CI pipeline
if (str_starts_with($clientId, "Client Id")) {
echo "clientId not configured. Skip this snippet test";
return;
}

$url = 'https://id.aspose.cloud/connect/token';
$url = 'https://id.aspose.cloud/connect/token';

$data = [
'grant_type' => 'client_credentials',
'client_id' => $clientId,
'client_secret' => $clientSecret
];
$data = [
'grant_type' => 'client_credentials',
'client_id' => $clientId,
'client_secret' => $clientSecret
];

$client = new Client();
$client = new Client();

$response = $client->post($url, [
'form_params' => $data,
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded'
]
]);
$response = $client->post($url, [
'form_params' => $data,
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded'
]
]);

$body = $response->getBody()->getContents();
$statusCode = $response->getStatusCode();
$body = $response->getBody()->getContents();
$statusCode = $response->getStatusCode();

if ($statusCode >= 200 && $statusCode < 300) {
$bodyArray=json_decode($body, true);
$token=$bodyArray["access_token"];
echo "Token recieved successfully\n";
// To veiw token uncomment next line
// echo "$token";
if ($statusCode >= 200 && $statusCode < 300) {
$bodyArray=json_decode($body, true);
$token=$bodyArray["access_token"];
echo "Token recieved successfully\n";
// To veiw token uncomment next line
// echo "$token";

} else {
throw new Exception("Unexpected HTTP code: $statusCode\nResponse: $body\n");
}
} else {
throw new Exception("Unexpected HTTP code: $statusCode\nResponse: $body\n");
}
5 changes: 3 additions & 2 deletions snippets/generate/appearance/GenerateGet.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ function main(): void

$request = new GenerateRequestWrapper(
EncodeBarcodeType::QR,
'Aspose.BarCode.Cloud');
'Aspose.BarCode.Cloud'
);
$request->image_format = BarcodeImageFormat::Png;
$request->foreground_color = 'Black';
$request->background_color = 'White';
Expand All @@ -48,4 +49,4 @@ function main(): void
echo "File '{$fileName}' generated.\n";
}

main();
main();
2 changes: 1 addition & 1 deletion snippets/generate/appearance/GenerateMultipart.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ function main(): void
echo "File '{$fileName}' generated.\n";
}

main();
main();
2 changes: 1 addition & 1 deletion snippets/generate/save/GenerateBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ function main(): void
echo "File '{$fileName}' generated.\n";
}

main();
main();
2 changes: 1 addition & 1 deletion snippets/generate/save/GenerateGet.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ function main(): void
echo "File '{$fileName}' generated.\n";
}

main();
main();
4 changes: 2 additions & 2 deletions snippets/generate/save/GenerateMultipart.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function main(): void
$fileName = __DIR__ . '/../testdata/Pdf417.png';

$generateApi = new GenerateApi(null, makeConfiguration());

$request = new GenerateMultipartRequestWrapper(EncodeBarcodeType::Pdf417, "Aspose.BarCode.Cloud");

$generated = $generateApi->generateMultipart($request);
Expand All @@ -39,4 +39,4 @@ function main(): void
echo "File '{$fileName}' generated.\n";
}

main();
main();
2 changes: 1 addition & 1 deletion snippets/generate/set-colorscheme/GenerateBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ function main(): void
echo "File '{$fileName}' generated.\n";
}

main();
main();
2 changes: 1 addition & 1 deletion snippets/generate/set-colorscheme/GenerateGet.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ function main(): void
echo "File '{$fileName}' generated.\n";
}

main();
main();
4 changes: 2 additions & 2 deletions snippets/generate/set-colorscheme/GenerateMultipart.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ function main(): void

$generated = $generateApi->generateMultipart($request);

file_put_contents($fileName, $generated->fread($generated->getSize()));
file_put_contents($fileName, $generated->fread($generated->getSize()));

echo "File '{$fileName}' generated.\n";
}

main();
main();
6 changes: 3 additions & 3 deletions snippets/generate/set-size/GenerateBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function main(): void
$fileName = __DIR__ . '/../testdata/../Pdf417.png';

$generateApi = new GenerateApi(null, makeConfiguration());

$generateParams = new GenerateParams([
'barcode_type' => EncodeBarcodeType::Pdf417,
'encode_data' => new EncodeData([
Expand All @@ -47,9 +47,9 @@ function main(): void
$request = new GenerateBodyRequestWrapper($generateParams);
$generated = $generateApi->generateBody($request);

file_put_contents($fileName, $generated->fread($generated->getSize()));
file_put_contents($fileName, $generated->fread($generated->getSize()));

echo "File '{$fileName}' generated.\n";
}

main();
main();
4 changes: 2 additions & 2 deletions snippets/generate/set-size/GenerateGet.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function main(): void
$request->image_width = 200;
$request->resolution = 300;
$request->units = 'Pixel';


$generated = $generateApi->generate($request);

Expand All @@ -44,4 +44,4 @@ function main(): void
echo "File '{$fileName}' generated.\n";
}

main();
main();
6 changes: 3 additions & 3 deletions snippets/generate/set-size/GenerateMultipart.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function makeConfiguration(): Configuration

function main(): void
{
$fileName = __DIR__ . '/../testdata/Aztec.png';
$fileName = __DIR__ . '/../testdata/aztec.png';

$generateApi = new GenerateApi(null, makeConfiguration());

Expand All @@ -36,12 +36,12 @@ function main(): void
$request->image_width = 200;
$request->resolution = 150;
$request->units = 'Point';

$generated = $generateApi->generateMultipart($request);

file_put_contents($fileName, $generated->fread($generated->getSize()));

echo "File '{$fileName}' generated.\n";
}

main();
main();
2 changes: 1 addition & 1 deletion snippets/generate/set-text/GenerateBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ function main(): void
echo "File '{$fileName}' generated.\n";
}

main();
main();
2 changes: 1 addition & 1 deletion snippets/generate/set-text/GenerateGet.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ function main(): void
echo "File '{$fileName}' generated.\n";
}

main();
main();
4 changes: 2 additions & 2 deletions snippets/generate/set-text/GenerateMultipart.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ function main(): void

$generated = $generateApi->generateMultipart($formRequest);

file_put_contents($fileName, $generated->fread($generated->getSize()));
file_put_contents($fileName, $generated->fread($generated->getSize()));

echo "File '{$fileName}' generated.\n";
}

main();
main();
4 changes: 2 additions & 2 deletions snippets/read/set-image-kind/RecognizeGet.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function makeConfiguration()
function main()
{
$recognizeApi = new RecognizeApi(null, makeConfiguration());

$request = new RecognizeRequestWrapper(DecodeBarcodeType::QR, "https://products.aspose.app/barcode/scan/img/how-to/scan/step2.png");
$request->image_kind = RecognitionImageKind::Photo;

Expand All @@ -34,4 +34,4 @@ function main()
echo sprintf("File '%s' recognized, result: '%s'\n", "https://products.aspose.app/barcode/scan/img/how-to/scan/step2.png", $result->getBarcodes()[0]->getBarcodeValue());
}

main();
main();
4 changes: 2 additions & 2 deletions snippets/read/set-image-kind/RecognizeMultipart.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function main()
$recognizeApi = new RecognizeApi(null, makeConfiguration());

$fileName = __DIR__ . '/../testdata/Pdf417.png';
$file = new SplFileObject($fileName, 'rb');
$file = new SplFileObject($fileName, 'rb');
$request = new RecognizeMultipartRequestWrapper(DecodeBarcodeType::MostCommonlyUsed, $file);
$request->image_kind = RecognitionImageKind::ClearImage;

Expand All @@ -36,4 +36,4 @@ function main()
echo sprintf("File '%s' recognized, result: '%s'\n", $fileName, $result->getBarcodes()[0]->getBarcodeValue());
}

main();
main();
2 changes: 1 addition & 1 deletion snippets/read/set-quality/RecognizeBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ function main()
);
}

main();
main();
2 changes: 1 addition & 1 deletion snippets/read/set-quality/RecognizeGet.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ function main()
);
}

main();
main();
10 changes: 5 additions & 5 deletions snippets/read/set-quality/RecognizeMultipart.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ function main()
{
$recognizeApi = new RecognizeApi(null, makeConfiguration());

$fileName = __DIR__ . '/../testdata/Aztec.png';
$file = new SplFileObject($fileName, 'rb');
$fileName = __DIR__ . '/../testdata/aztec.png';
$file = new SplFileObject($fileName, 'rb');

$request = new RecognizeMultipartRequestWrapper(DecodeBarcodeType::Aztec, $file);
$request->recognition_mode = RecognitionMode::Normal;
$request->image_kind = RecognitionImageKind::ScannedDocument;

$result = $recognizeApi->recognizeMultipart($request);

echo sprintf(
"File '%s' recognized, result: '%s'\n",
$fileName,
$result->getBarcodes()[0]->getBarcodeValue()
);
}

main();
main();
2 changes: 1 addition & 1 deletion snippets/read/set-source/RecognizeBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ function main()
);
}

main();
main();
2 changes: 1 addition & 1 deletion snippets/read/set-source/RecognizeGet.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ function main()
);
}

main();
main();
4 changes: 2 additions & 2 deletions snippets/read/set-source/RecognizeMultipart.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function main()
$recognizeApi = new RecognizeApi(null, makeConfiguration());

$fileName = __DIR__ . '/../testdata/Qr.png';
$file = new SplFileObject($fileName, 'rb');
$file = new SplFileObject($fileName, 'rb');

$request = new RecognizeMultipartRequestWrapper(
DecodeBarcodeType::QR,
Expand All @@ -45,4 +45,4 @@ function main()
$file = null;
}

main();
main();
2 changes: 1 addition & 1 deletion snippets/read/set-source/ScanBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ function main()
);
}

main();
main();
2 changes: 1 addition & 1 deletion snippets/read/set-source/ScanGet.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ function main()
);
}

main();
main();
4 changes: 2 additions & 2 deletions snippets/read/set-source/ScanMultipart.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ function main()
$fileName = __DIR__ . '/../testdata/Qr.png';
$file = new SplFileObject($fileName, 'rb');
$request = new ScanMultipartRequestWrapper($file);

$result = $scanApi->scanMultipart($request);
$file = null;

echo sprintf("File '%s' recognized, result: '%s'\n", $fileName, $result->getBarcodes()[0]->getBarcodeValue());
}

main();
main();
Loading