Q:
I’m trying to use your PWS Cloud API to download an XOD file (with PHP).
Using the API I’ve managed to upload a PDF with callback, then get the documentId and retrieve the document status (xodState). But I’m stuck trying to download the XOD.
Here is my code
`
<?php function RetrieveDocument($documentId) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, PDFTRON_API_URL_SECURE.'/document/'.$documentId.'/download?type=xod'); curl_setopt($ch, CURLOPT_USERPWD, MY_API_KEY.':'.MY_SECRET); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.001 (windows; U; NT4.0; en-US; rv:1.0) Gecko/25250101'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //configure cURL to accept any server certificate curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); return $response; } ?>`
A:
The API method call to download the XOD returns a redirect response to the actual location of the file.
You can get the XOD data with the following cURL option:
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
In the redirect=false response, it should give back the correct file URL unless the document has been deleted or has an error.