-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from datalogics-tsmith/raw-json-calls-php
PDFCLOUD-2825 Add upload + raw JSON php samples
- Loading branch information
Showing
34 changed files
with
1,189 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This directory contains examples of how to call each endpoint of the | ||
PdfRest API using PHP. Please refer to https://pdfrest.com/documentation.html | ||
for accepted inputs, options, and other specifics about individual endpoints. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
require 'vendor/autoload.php'; // Require the autoload file to load Guzzle HTTP client. | ||
|
||
use GuzzleHttp\Client; // Import the Guzzle HTTP client namespace. | ||
use GuzzleHttp\Psr7\Request; // Import the PSR-7 Request class. | ||
use GuzzleHttp\Psr7\Utils; // Import the PSR-7 Utils class for working with streams. | ||
|
||
$upload_client = new Client(['http_errors' => false]); | ||
$upload_headers = [ | ||
'api-key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', | ||
'content-filename' => 'filename.pdf', | ||
'Content-Type' => 'application/octet-stream' | ||
]; | ||
$upload_body = file_get_contents('/path/to/file'); | ||
$upload_request = new Request('POST', 'https://api.pdfrest.com/upload', $upload_headers, $upload_body); | ||
$upload_res = $upload_client->sendAsync($upload_request)->wait(); | ||
echo $upload_res->getBody() . PHP_EOL; | ||
|
||
$upload_response_json = json_decode($upload_res->getBody()); | ||
|
||
$uploaded_id = $upload_response_json->{'files'}[0]->{'id'}; | ||
|
||
echo "Successfully uploaded with an id of: " . $uploaded_id . PHP_EOL; | ||
|
||
$bmp_client = new Client(['http_errors' => false]); | ||
$bmp_headers = [ | ||
'api-key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', | ||
'Content-Type' => 'application/json' | ||
]; | ||
$bmp_body = '{"id":"'.$uploaded_id.'"}'; | ||
$bmp_request = new Request('POST', 'https://api.pdfrest.com/bmp', $bmp_headers, $bmp_body); | ||
$bmp_res = $bmp_client->sendAsync($bmp_request)->wait(); | ||
echo $bmp_res->getBody() . PHP_EOL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
require 'vendor/autoload.php'; // Require the autoload file to load Guzzle HTTP client. | ||
|
||
use GuzzleHttp\Client; // Import the Guzzle HTTP client namespace. | ||
use GuzzleHttp\Psr7\Request; // Import the PSR-7 Request class. | ||
use GuzzleHttp\Psr7\Utils; // Import the PSR-7 Utils class for working with streams. | ||
|
||
$upload_client = new Client(['http_errors' => false]); | ||
$upload_headers = [ | ||
'api-key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', | ||
'content-filename' => 'filename.pdf', | ||
'Content-Type' => 'application/octet-stream' | ||
]; | ||
$upload_body = file_get_contents('/path/to/file'); | ||
$upload_request = new Request('POST', 'https://api.pdfrest.com/upload', $upload_headers, $upload_body); | ||
$upload_res = $upload_client->sendAsync($upload_request)->wait(); | ||
echo $upload_res->getBody() . PHP_EOL; | ||
|
||
$upload_response_json = json_decode($upload_res->getBody()); | ||
|
||
$uploaded_id = $upload_response_json->{'files'}[0]->{'id'}; | ||
|
||
echo "Successfully uploaded with an id of: " . $uploaded_id . PHP_EOL; | ||
|
||
$compress_client = new Client(['http_errors' => false]); | ||
$compress_headers = [ | ||
'api-key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', | ||
'Content-Type' => 'application/json' | ||
]; | ||
$compress_body = '{"id":"'.$uploaded_id.'", "compression_level": "medium"}'; | ||
$compress_request = new Request('POST', 'https://api.pdfrest.com/compressed-pdf', $compress_headers, $compress_body); | ||
$compress_res = $compress_client->sendAsync($compress_request)->wait(); | ||
echo $compress_res->getBody() . PHP_EOL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
require 'vendor/autoload.php'; // Require the autoload file to load Guzzle HTTP client. | ||
|
||
use GuzzleHttp\Client; // Import the Guzzle HTTP client namespace. | ||
use GuzzleHttp\Psr7\Request; // Import the PSR-7 Request class. | ||
use GuzzleHttp\Psr7\Utils; // Import the PSR-7 Utils class for working with streams. | ||
|
||
$upload_client = new Client(['http_errors' => false]); | ||
$upload_headers = [ | ||
'api-key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', | ||
'content-filename' => 'filename.pdf', | ||
'Content-Type' => 'application/octet-stream' | ||
]; | ||
$upload_body = file_get_contents('/path/to/file'); | ||
$upload_request = new Request('POST', 'https://api.pdfrest.com/upload', $upload_headers, $upload_body); | ||
$upload_res = $upload_client->sendAsync($upload_request)->wait(); | ||
echo $upload_res->getBody() . PHP_EOL; | ||
|
||
$upload_response_json = json_decode($upload_res->getBody()); | ||
|
||
$uploaded_id = $upload_response_json->{'files'}[0]->{'id'}; | ||
|
||
echo "Successfully uploaded with an id of: " . $uploaded_id . PHP_EOL; | ||
|
||
$decrypt_client = new Client(['http_errors' => false]); | ||
$decrypt_headers = [ | ||
'api-key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', | ||
'Content-Type' => 'application/json' | ||
]; | ||
$decrypt_body = '{"id":"'.$uploaded_id.'", "current_open_password": "password"}'; | ||
$decrypt_request = new Request('POST', 'https://api.pdfrest.com/decrypted-pdf', $decrypt_headers, $decrypt_body); | ||
$decrypt_res = $decrypt_client->sendAsync($decrypt_request)->wait(); | ||
echo $decrypt_res->getBody() . PHP_EOL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
require 'vendor/autoload.php'; // Require the autoload file to load Guzzle HTTP client. | ||
|
||
use GuzzleHttp\Client; // Import the Guzzle HTTP client namespace. | ||
use GuzzleHttp\Psr7\Request; // Import the PSR-7 Request class. | ||
use GuzzleHttp\Psr7\Utils; // Import the PSR-7 Utils class for working with streams. | ||
|
||
$upload_client = new Client(['http_errors' => false]); | ||
$upload_headers = [ | ||
'api-key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', | ||
'content-filename' => 'filename.pdf', | ||
'Content-Type' => 'application/octet-stream' | ||
]; | ||
$upload_body = file_get_contents('/path/to/file'); | ||
$upload_request = new Request('POST', 'https://api.pdfrest.com/upload', $upload_headers, $upload_body); | ||
$upload_res = $upload_client->sendAsync($upload_request)->wait(); | ||
echo $upload_res->getBody() . PHP_EOL; | ||
|
||
$upload_response_json = json_decode($upload_res->getBody()); | ||
|
||
$uploaded_id = $upload_response_json->{'files'}[0]->{'id'}; | ||
|
||
echo "Successfully uploaded with an id of: " . $uploaded_id . PHP_EOL; | ||
|
||
$encrypt_client = new Client(['http_errors' => false]); | ||
$encrypt_headers = [ | ||
'api-key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', | ||
'Content-Type' => 'application/json' | ||
]; | ||
$encrypt_body = '{"id":"'.$uploaded_id.'", "new_open_password": "password"}'; | ||
$encrypt_request = new Request('POST', 'https://api.pdfrest.com/encrypted-pdf', $encrypt_headers, $encrypt_body); | ||
$encrypt_res = $encrypt_client->sendAsync($encrypt_request)->wait(); | ||
echo $encrypt_res->getBody() . PHP_EOL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
require 'vendor/autoload.php'; // Require the autoload file to load Guzzle HTTP client. | ||
|
||
use GuzzleHttp\Client; // Import the Guzzle HTTP client namespace. | ||
use GuzzleHttp\Psr7\Request; // Import the PSR-7 Request class. | ||
use GuzzleHttp\Psr7\Utils; // Import the PSR-7 Utils class for working with streams. | ||
|
||
$upload_client = new Client(['http_errors' => false]); | ||
$upload_headers = [ | ||
'api-key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', | ||
'content-filename' => 'filename.pdf', | ||
'Content-Type' => 'application/octet-stream' | ||
]; | ||
$upload_body = file_get_contents('/path/to/file'); | ||
$upload_request = new Request('POST', 'https://api.pdfrest.com/upload', $upload_headers, $upload_body); | ||
$upload_res = $upload_client->sendAsync($upload_request)->wait(); | ||
echo $upload_res->getBody() . PHP_EOL; | ||
|
||
$upload_response_json = json_decode($upload_res->getBody()); | ||
|
||
$uploaded_id = $upload_response_json->{'files'}[0]->{'id'}; | ||
|
||
echo "Successfully uploaded with an id of: " . $uploaded_id . PHP_EOL; | ||
|
||
$excel_client = new Client(['http_errors' => false]); | ||
$excel_headers = [ | ||
'api-key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', | ||
'Content-Type' => 'application/json' | ||
]; | ||
$excel_body = '{"id":"'.$uploaded_id.'"}'; | ||
$excel_request = new Request('POST', 'https://api.pdfrest.com/excel', $excel_headers, $excel_body); | ||
$excel_res = $excel_client->sendAsync($excel_request)->wait(); | ||
echo $excel_res->getBody() . PHP_EOL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
require 'vendor/autoload.php'; // Require the autoload file to load Guzzle HTTP client. | ||
|
||
use GuzzleHttp\Client; // Import the Guzzle HTTP client namespace. | ||
use GuzzleHttp\Psr7\Request; // Import the PSR-7 Request class. | ||
use GuzzleHttp\Psr7\Utils; // Import the PSR-7 Utils class for working with streams. | ||
|
||
$upload_client = new Client(['http_errors' => false]); | ||
$upload_headers = [ | ||
'api-key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', | ||
'content-filename' => 'filename.pdf', | ||
'Content-Type' => 'application/octet-stream' | ||
]; | ||
$upload_body = file_get_contents('/path/to/file'); | ||
$upload_request = new Request('POST', 'https://api.pdfrest.com/upload', $upload_headers, $upload_body); | ||
$upload_res = $upload_client->sendAsync($upload_request)->wait(); | ||
echo $upload_res->getBody() . PHP_EOL; | ||
|
||
$upload_response_json = json_decode($upload_res->getBody()); | ||
|
||
$uploaded_id = $upload_response_json->{'files'}[0]->{'id'}; | ||
|
||
echo "Successfully uploaded with an id of: " . $uploaded_id . PHP_EOL; | ||
|
||
$export_client = new Client(['http_errors' => false]); | ||
$export_headers = [ | ||
'api-key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', | ||
'Content-Type' => 'application/json' | ||
]; | ||
$export_body = '{"id":"'.$uploaded_id.'", "data_format": "xml"}'; | ||
$export_request = new Request('POST', 'https://api.pdfrest.com/exported-form-data', $export_headers, $export_body); | ||
$export_res = $export_client->sendAsync($export_request)->wait(); | ||
echo $export_res->getBody() . PHP_EOL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
require 'vendor/autoload.php'; // Require the autoload file to load Guzzle HTTP client. | ||
|
||
use GuzzleHttp\Client; // Import the Guzzle HTTP client namespace. | ||
use GuzzleHttp\Psr7\Request; // Import the PSR-7 Request class. | ||
use GuzzleHttp\Psr7\Utils; // Import the PSR-7 Utils class for working with streams. | ||
|
||
$upload_client = new Client(['http_errors' => false]); | ||
$upload_headers = [ | ||
'api-key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', | ||
'content-filename' => 'filename.pdf', | ||
'Content-Type' => 'application/octet-stream' | ||
]; | ||
$upload_body = file_get_contents('/path/to/file'); | ||
$upload_request = new Request('POST', 'https://api.pdfrest.com/upload', $upload_headers, $upload_body); | ||
$upload_res = $upload_client->sendAsync($upload_request)->wait(); | ||
echo $upload_res->getBody() . PHP_EOL; | ||
|
||
$upload_response_json = json_decode($upload_res->getBody()); | ||
|
||
$uploaded_id = $upload_response_json->{'files'}[0]->{'id'}; | ||
|
||
echo "Successfully uploaded with an id of: " . $uploaded_id . PHP_EOL; | ||
|
||
$extract_client = new Client(['http_errors' => false]); | ||
$extract_headers = [ | ||
'api-key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', | ||
'Content-Type' => 'application/json' | ||
]; | ||
$extract_body = '{"id":"'.$uploaded_id.'"}'; | ||
$extract_request = new Request('POST', 'https://api.pdfrest.com/extracted-text', $extract_headers, $extract_body); | ||
$extract_res = $extract_client->sendAsync($extract_request)->wait(); | ||
echo $extract_res->getBody() . PHP_EOL; |
33 changes: 33 additions & 0 deletions
33
PHP/Endpoint Examples/JSON Payload/flattened-annotations-pdf.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
require 'vendor/autoload.php'; // Require the autoload file to load Guzzle HTTP client. | ||
|
||
use GuzzleHttp\Client; // Import the Guzzle HTTP client namespace. | ||
use GuzzleHttp\Psr7\Request; // Import the PSR-7 Request class. | ||
use GuzzleHttp\Psr7\Utils; // Import the PSR-7 Utils class for working with streams. | ||
|
||
$upload_client = new Client(['http_errors' => false]); | ||
$upload_headers = [ | ||
'api-key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', | ||
'content-filename' => 'filename.pdf', | ||
'Content-Type' => 'application/octet-stream' | ||
]; | ||
$upload_body = file_get_contents('/path/to/file'); | ||
$upload_request = new Request('POST', 'https://api.pdfrest.com/upload', $upload_headers, $upload_body); | ||
$upload_res = $upload_client->sendAsync($upload_request)->wait(); | ||
echo $upload_res->getBody() . PHP_EOL; | ||
|
||
$upload_response_json = json_decode($upload_res->getBody()); | ||
|
||
$uploaded_id = $upload_response_json->{'files'}[0]->{'id'}; | ||
|
||
echo "Successfully uploaded with an id of: " . $uploaded_id . PHP_EOL; | ||
|
||
$flatten_client = new Client(['http_errors' => false]); | ||
$flatten_headers = [ | ||
'api-key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', | ||
'Content-Type' => 'application/json' | ||
]; | ||
$flatten_body = '{"id":"'.$uploaded_id.'"}'; | ||
$flatten_request = new Request('POST', 'https://api.pdfrest.com/flattened-annotations-pdf', $flatten_headers, $flatten_body); | ||
$flatten_res = $flatten_client->sendAsync($flatten_request)->wait(); | ||
echo $flatten_res->getBody() . PHP_EOL; |
33 changes: 33 additions & 0 deletions
33
PHP/Endpoint Examples/JSON Payload/flattened-forms-pdf.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
require 'vendor/autoload.php'; // Require the autoload file to load Guzzle HTTP client. | ||
|
||
use GuzzleHttp\Client; // Import the Guzzle HTTP client namespace. | ||
use GuzzleHttp\Psr7\Request; // Import the PSR-7 Request class. | ||
use GuzzleHttp\Psr7\Utils; // Import the PSR-7 Utils class for working with streams. | ||
|
||
$upload_client = new Client(['http_errors' => false]); | ||
$upload_headers = [ | ||
'api-key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', | ||
'content-filename' => 'filename.pdf', | ||
'Content-Type' => 'application/octet-stream' | ||
]; | ||
$upload_body = file_get_contents('/path/to/file'); | ||
$upload_request = new Request('POST', 'https://api.pdfrest.com/upload', $upload_headers, $upload_body); | ||
$upload_res = $upload_client->sendAsync($upload_request)->wait(); | ||
echo $upload_res->getBody() . PHP_EOL; | ||
|
||
$upload_response_json = json_decode($upload_res->getBody()); | ||
|
||
$uploaded_id = $upload_response_json->{'files'}[0]->{'id'}; | ||
|
||
echo "Successfully uploaded with an id of: " . $uploaded_id . PHP_EOL; | ||
|
||
$flatten_client = new Client(['http_errors' => false]); | ||
$flatten_headers = [ | ||
'api-key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', | ||
'Content-Type' => 'application/json' | ||
]; | ||
$flatten_body = '{"id":"'.$uploaded_id.'"}'; | ||
$flatten_request = new Request('POST', 'https://api.pdfrest.com/flattened-forms-pdf', $flatten_headers, $flatten_body); | ||
$flatten_res = $flatten_client->sendAsync($flatten_request)->wait(); | ||
echo $flatten_res->getBody() . PHP_EOL; |
33 changes: 33 additions & 0 deletions
33
PHP/Endpoint Examples/JSON Payload/flattened-layers-pdf.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
require 'vendor/autoload.php'; // Require the autoload file to load Guzzle HTTP client. | ||
|
||
use GuzzleHttp\Client; // Import the Guzzle HTTP client namespace. | ||
use GuzzleHttp\Psr7\Request; // Import the PSR-7 Request class. | ||
use GuzzleHttp\Psr7\Utils; // Import the PSR-7 Utils class for working with streams. | ||
|
||
$upload_client = new Client(['http_errors' => false]); | ||
$upload_headers = [ | ||
'api-key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', | ||
'content-filename' => 'filename.pdf', | ||
'Content-Type' => 'application/octet-stream' | ||
]; | ||
$upload_body = file_get_contents('/path/to/file'); | ||
$upload_request = new Request('POST', 'https://api.pdfrest.com/upload', $upload_headers, $upload_body); | ||
$upload_res = $upload_client->sendAsync($upload_request)->wait(); | ||
echo $upload_res->getBody() . PHP_EOL; | ||
|
||
$upload_response_json = json_decode($upload_res->getBody()); | ||
|
||
$uploaded_id = $upload_response_json->{'files'}[0]->{'id'}; | ||
|
||
echo "Successfully uploaded with an id of: " . $uploaded_id . PHP_EOL; | ||
|
||
$flatten_client = new Client(['http_errors' => false]); | ||
$flatten_headers = [ | ||
'api-key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', | ||
'Content-Type' => 'application/json' | ||
]; | ||
$flatten_body = '{"id":"'.$uploaded_id.'"}'; | ||
$flatten_request = new Request('POST', 'https://api.pdfrest.com/flattened-layers-pdf', $flatten_headers, $flatten_body); | ||
$flatten_res = $flatten_client->sendAsync($flatten_request)->wait(); | ||
echo $flatten_res->getBody() . PHP_EOL; |
33 changes: 33 additions & 0 deletions
33
PHP/Endpoint Examples/JSON Payload/flattened-transparencies-pdf.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
require 'vendor/autoload.php'; // Require the autoload file to load Guzzle HTTP client. | ||
|
||
use GuzzleHttp\Client; // Import the Guzzle HTTP client namespace. | ||
use GuzzleHttp\Psr7\Request; // Import the PSR-7 Request class. | ||
use GuzzleHttp\Psr7\Utils; // Import the PSR-7 Utils class for working with streams. | ||
|
||
$upload_client = new Client(['http_errors' => false]); | ||
$upload_headers = [ | ||
'api-key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', | ||
'content-filename' => 'filename.pdf', | ||
'Content-Type' => 'application/octet-stream' | ||
]; | ||
$upload_body = file_get_contents('/path/to/file'); | ||
$upload_request = new Request('POST', 'https://api.pdfrest.com/upload', $upload_headers, $upload_body); | ||
$upload_res = $upload_client->sendAsync($upload_request)->wait(); | ||
echo $upload_res->getBody() . PHP_EOL; | ||
|
||
$upload_response_json = json_decode($upload_res->getBody()); | ||
|
||
$uploaded_id = $upload_response_json->{'files'}[0]->{'id'}; | ||
|
||
echo "Successfully uploaded with an id of: " . $uploaded_id . PHP_EOL; | ||
|
||
$flatten_client = new Client(['http_errors' => false]); | ||
$flatten_headers = [ | ||
'api-key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', | ||
'Content-Type' => 'application/json' | ||
]; | ||
$flatten_body = '{"id":"'.$uploaded_id.'"}'; | ||
$flatten_request = new Request('POST', 'https://api.pdfrest.com/flattened-transparencies-pdf', $flatten_headers, $flatten_body); | ||
$flatten_res = $flatten_client->sendAsync($flatten_request)->wait(); | ||
echo $flatten_res->getBody() . PHP_EOL; |
Oops, something went wrong.