copied the code example from Compare Word Documents documentation article.
used our own file paths for the “request document” and “comparing with document”
tried different values with the destination filename and all return the same 404 message:
[404] Error connecting to the API (https://api.aspose.cloud/v4.0/words/online/put/compareDocument?destFileName=TestCompareDocumentOut.docx
)
tried step debug through the sdk to see if we were misunderstanding a value. we may be but it’s nothing obvious if we are.
also, the PHP example is incorrect. it passes 6 arguments to a constructor that only has 5 so our code has line 16-18 as
$compareOnlineRequest = new CompareDocumentOnlineRequest(
$requestDocument, $requestCompareData, null, null, 'TestCompareDocumentOut.docx'
);
@blueburro
It seems you are getting the error due to the difference in the number of arguments. We compared two Word Documents using the latest version of Aspose.Words Cloud SDK for PHP by following these steps without any issue.
Steps to Compare Two Word Documents in PHP
- Sign up with Aspose.Cloud and get credentials
- Install Aspose.Words Cloud SDK for PHP from Packagist
- Create a PHP script file for the code
- Add reference of Aspose.Words Cloud SDK for PHP
- Upload Revised Word Document to Cloud Storage using UploadFile API Method
- Compare Original Word Document with Revised Word Document using Compare API method and return the revisions document in response
- Save revisions document to a local drive
Code to Compare Two Word Documents in PHP
<?php
require_once('D:\xampp\htdocs\aspose-words-cloud-php-master\vendor\autoload.php');
//TODO: Get your ClientId and ClientSecret at https://dashboard.aspose.cloud (free registration is required).
$ClientId="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx";
$ClientSecret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$wordsApi = new Aspose\Words\WordsApi($ClientId,$ClientSecret);
try {
$remoteFolder = "Temp";
$sourceFileName = "Source.doc";
$revisedFileName = "Revised.doc";
$remoteRevisedFileName = "Revised.doc";
$outputFileName = "CompareDocumentOutput.doc";
$uploadRequest = new Aspose\Words\Model\Requests\UploadFileRequest($revisedFileName,$remoteFolder."/".$remoteRevisedFileName,null);
$wordsApi->uploadFile($uploadRequest);
$requestDocument = $sourceFileName;
$requestCompareData = new Aspose\Words\Model\CompareData(array(
"author" => "author",
"comparing_with_document" => $remoteFolder . "/" . $remoteRevisedFileName,
"date_time" => new \DateTime("2015-10-26T00:00:00.0000000Z"),
));
$request = new Aspose\Words\Model\Requests\CompareDocumentOnlineRequest(
$requestDocument,
$requestCompareData,
NULL,
NULL,
NULL,
NULL ##$remoteFolder ."/". $outputFileName
);
$result = $wordsApi->compareDocumentOnline($request);
##Save output file to local drive
copy($result->document->getPathName(),$outputFileName);
print_r($result->document->getPathName());
##Download file from stroage
#$downloadRequest = new Aspose\Words\Model\Requests\DownloadFileRequest($remoteFolder."/".$outputFileName,NULL,NULL);
#$downloadResult = $wordsApi->downloadFile($downloadRequest);
#copy($downloadResult->getPathName(),$outputFileName);
#print_r($downloadResult);
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
PHP_EOL;
}
?>
You may also check sample unit tests and CompareDocumentOnlineRequest definition from GitHub for reference.
Furthermore, we noticed that the CompareDocumentOnline method is not saving the output document to Cloud Storage as expected. We are investigating the issue(WORDSCLOUD-1748) and will update you as soon as possible However, meanwhile, you can save the output document with revisions to your local drive as suggested above.
Ok. part of the issue is we’re locked to 21.4.0
and it looks like 21.9.0
is what the example uses.
I updated the dependency to 21.9.0
and tried the suggested code. We definitely want to get a local copy to consume.
We are NOT wanting to save to the cloud storage if possible. This should work until the issue (WORDSCLOUD-1748) you mentioned is resolved. Am I understanding correctly that resolving the WORDSCLOUD-1748 issue will allow us to NOT have to upload/store on the cloud storage?
Side note/question: Shouldn’t whatever version introduced that refactor have made the version into 22.0.0 because of backwards compatibility break?
Thank you for your help and quick reply.
@blueburro
No, if you do not want to save the output to Cloud Storage then use the above shared code. So, you do not need the resolution of WORDSCLOUD-1748. And if you do not want to use the external storage at all then you may check our self-hosting Docker Container solution of Aspose.Words Cloud.
I’m afraid the backward compatibility of an SDK will break with any breaking change in the Cloud API. However, you can control it somehow but can not avoid completely, by hosting the Cloud API at your site using Aspose.Words Cloud Docker Container. As we always add fixes/new features in the latest release of the Cloud API.
The issues you have found earlier (filed as WORDSCLOUD-1748) have been fixed in Aspose.Words Cloud SDK for PHP 21.12 update. This message was posted using Bugs notification tool by Ivanov_John