We're sorry AsposeCloud doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.cloud

Php curl cell not posting files

Here is my php code to uplaod a xlsx file and protect it.

Missing something which is not working. Can anyone help !

//$bearer_token => Authentication token
//$sourceFolder => Folder where file exists
//$fileName => abdc.xlsx

		$protectxlsx_url = "https://api.aspose.cloud/v3.0/cells/protect?password=123456";
		$protectxlsx_headers = array(
			"Content-Type: application/json",
			"Accept: application/json",
			"Authorization: Bearer ".$bearer_token."",
		//var_dump(mime_content_type($sourceFolder.$fileName));  die;

		$tmp_file = curl_file_create($sourceFolder.$fileName);

		//$file_realpath = curl_file_create($fileSave);
		$protectxlsx_ch = curl_init();
		curl_setopt($protectxlsx_ch, CURLOPT_URL, $protectxlsx_url);
		curl_setopt($protectxlsx_ch, CURLOPT_POST, true);
		curl_setopt($protectxlsx_ch, CURLOPT_POSTFIELDS, $tmp_file);
		curl_setopt($protectxlsx_ch, CURLOPT_HTTPHEADER, $protectxlsx_headers);			
		$protectxlsx_apiresult = curl_exec($protectxlsx_ch);
		$protectxlsx_apiresult_jsondecode = json_decode($protectxlsx_apiresult, true);

		//$protectxlsx_apiresult_jsondecode => not generating any data


We suggest you use Aspose.Cells Cloud SDK for PHP.
Aspose.Cells Cloud SDK for PHP is open-source on GitHub.
Please check the following example code:

use \Aspose\Cells\Cloud\Api\LightCellsApi;
$cells = new LightCellsApi( getenv(“ProductClientId”),getenv(“ProductClientSecret”) );
$files = array (
‘DataSource’ => “D:/projects/aspose/examples/testdata/source/datasource.xlsx”,
‘AssemblyTest’ => “D:/projects/aspose/examples/testdata/source/assemblytest.xlsx”
$result = $cells->postProtect( $files, ‘12345’ );
$filename = $result->getFiles()[0]->getFilename() ;
$fileData = $result->getFiles()[0]->getFileContent() ;
$ptr = fopen($filename, ‘wb’);
fwrite($ptr, base64_decode($fileData));


But the issue is everytime i Check for config.
It doesn’t returning accessToken
$configDtls = $cells->getConfig();
var_dump($configDtls); die;
Please can you verify ?
There is issue with LightCellsApi Object creation.

Some issue found like: On Line 87,97 of LightCellsApi.php $this->config ->setAccessToken has space in config call Like “config ->”. I have removed the space. But still not generating any token. Can you confirm ?

Thanks Again


We have tested your issues and can get an access token. Please try the example code.

use \Aspose\Cells\Cloud\Api\LightCellsApi;
$cells = new LightCellsApi( getenv(“ProductClientId”),getenv(“ProductClientSecret”) );

Please check the following question which cause can not access the token:

  1. Whether can access https://api.aspose.cloud normally. The following command is to test cells cloud services statue.

curl http://api.aspose.cloud/v3.0/cells

  1. Check that the entered client ID and client secret are correct. Please read the quick start online document about how to get the client ID and client secret.