score:1

Accepted answer

I suspect your issue is here:

curl_setopt($ch, CURLOPT_POSTFIELDS, $dataString);

I believe this is expecting a String or an Array.

This parameter can either be passed as a urlencoded string like 'para1=val1&para2=val2&...' or as an array with the field name as key and field data as value. If value is an array, the Content-Type header will be set to multipart/form-data. As of PHP 5.2.0, value must be an array if files are passed to this option with the @ prefix. As of PHP 5.5.0, the @ prefix is deprecated and files can be sent using CURLFile.

Consider trying the following:

$dataArray = array(
  "async" => true,
  "type" => "image/jpeg",
  "width" => 800,
  "options" => $DataEncoded
);

And...

curl_setopt($ch, CURLOPT_POSTFIELDS, $dataArray);

Credit to @Patrick Q for catching the Encoding Type. You're not exactly sending it JSON encoded data, but Form data essentially.

score:0

I used the recommendations of Twisty and finally I obtain the name of the image, thank you so much.

$dataString = ('async=true&type=image/jpeg&width=800&options='.$DataEncoded);
$url ='https://export.highcharts.com/?';
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$dataString);
curl_setopt($ch, CURLOPT_POST, 1);

$headers = array();
$headers[] = "Accept: application/json";
$headers[] = "Content-Type: application/x-www-form-urlencoded";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);

Related Query

More Query from same tag