Free Support Forum - aspose.cloud

Convert Microsoft Word Document to HTML in PHP using Aspose.Words REST API authentication issue

I have downloaded the API of the PHP and it’s my first application. Can you please help me to get the authentication for my first app?

@pathaksanketm

Thanks for your interest in Aspose. Please sign up with aspose.cloud and get your APP Key and SID for authentication.

I already have that. I have below queries:

  1. Where should we update our credentials after downloading the SDK
  2. What type of credentials I need to set before run the code
  3. If access token is required then how to generate it

@pathaksanketm

Thanks for your inquiry. Please note when you use the aspose.cloud SDKs, then you do not need to generate the access token yourself, SDK will take care of it. You only need to pass your credentials in your code. Please check the installation and sample usage section from readme file. For further reference please check a sample code snippet after installing PHP SDK from packagist.

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

use Aspose\Words\Configuration;
use Aspose\Words\WordsApi;
use Aspose\Words\Model\Requests;
use Aspose\Words\Model\SaveOptionsData;

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

$config = new Configuration();
$config->setAppKey('xxxxxxxxxxxxxxxxxxxxxx')->setAppSid('xxxxxx-xxxx-xxxx-xxxxx-xxxxx');
$words = new WordsApi(null, $config);

try {	

    $format = "docx";
    $file = "testbullet.html";
    $request = new Requests\ConvertDocumentRequest($file, $format);
    $result = $words->convertDocument($request);	
    print_r($result);	
    echo "Completed!!!!";
    
} catch (Exception $e) {
    echo  "Something went wrong: ",  $e->getMessage(), "\n";
    PHP_EOL;
}

?>