Free Support Forum - aspose.cloud

Getting Started


#1

I’m getting started on Aspose Cloud for Word in PHP. At the outset the experience so far has been highly frustrating. There is very few examples and no complete examples where I can see say an upload, merge, convert and download. My time has been spent looking at the composer code and trying to understand the results without any documentation.

Issue 1:
Calling getListFiles returns no results, I get a {} with an empty path (or I try directory) with or without the storage name. Nothing.

Issue 2:
Calling download file returns no results.

Issue 3:
Calling postDocumentExecuteMailMerge seems to work. I get an object back but I’m not able to do anything with [document][links][15][href]? I can an authentication denied in the browser when attempting the URL and I can’t see any methods on your SDK to download it?

Issue 4:
I’m unsure if I need Aspose PDF installed to also access PDFs after mail merge.

I would appreciate a prompt response. I’ve tried to be fairly patient but I’m not getting anywhere.

Tim


#2

@digeratisolutions

We are sorry for your inconvenience. We are in process of updating the examples of different platforms in the documentation. However, meanwhile you may please check complete unit test of APIs for the purpose.

I am creating a sample code for your other issues and will share it soon.


#3

Thanks Tilal,

A quick update. Issue 2 is no longer a problem, an ajax response was sanitizing the object data in my testing.


#4

@digeratisolutions

Thanks for your feedback.

The getListFiles is working fine at my end. Please find sample code below.

The postDocumentExecuteMailMerge saves output file to storage and returns possible options to convert resultant document to other supported formats. You can convert supported documents to other formats using GetDocumetnWithFormat API. You can also get the sample PHP unit test for it from github repo.

Yes, Please note if you want to manipulate the PDF file then you can use Aspose.Pdf Cloud API.

<?php

require_once('C:\xampp\htdocs\aspose-words-cloud-php-master\vendor\autoload.php');

//TODO: Get your AppSID and AppKey at https://dashboard.aspose.cloud (free registration is required).

$AppKey="xxxxxxxxxxxxxxxxxxxxx";
$AppSid="xxxxx-xxxx-xxxx-xxxx-xxxxxxxxx";

$configuration = new Aspose\Words\Configuration();
$configuration->setAppSid($AppSid);
$configuration->setAppKey($AppKey);

$wordsApi = new Aspose\Words\WordsApi(null,$configuration); 

$storageApi = new Aspose\Storage\Api\StorageApi();
$storageApi->getConfig()->setAppKey($AppKey)->setAppSid($AppSid);

try {
		
	## List the files and folders
	$path = "output";
    $storage = null;
    $request = new Aspose\Storage\Model\Requests\GetListFilesRequest($path, $storage);
    $result = $storageApi->getListFiles($request);
    print_r($result);		
		
		
	$templateName = "SampleMailMergeTemplate.docx";
    $outputName = "ExecuteMailMerge_output.docx";
	##read mailmerge data
    $data = file_get_contents("SampleMailMergeTemplateData.txt");
	##upload template file to storage
    $putRequest = new Aspose\Storage\Model\Requests\PutCreateRequest($templateName, $templateName);
    $storageApi->PutCreate($putRequest);
	##Execute MailMerge
    $request = new Aspose\Words\Model\Requests\PostDocumentExecuteMailMergeRequest($templateName, $data, null,null, null, null, null,null, null, false, $outputName);
    $result = $wordsApi->postDocumentExecuteMailMerge($request);
        		
	## Download a file 		
	$path = "ExecuteMailMerge_output.docx";
	$versionId = null;
    $storage = null;
    $request = new Aspose\Storage\Model\Requests\GetDownloadRequest($path, $versionId, $storage);
    $result = $storageApi->getDownload($request);	
    echo "Status: ",  $result->getSize();		
	

    
    
} catch (Exception $e) {
    echo  "Something went wrong: ",  $e->getMessage(), "\n";
    PHP_EOL;
}

?>