I have the following code and it is not working, I just get string(0) “”
This code is a copy of a DeepL curl script that creates a glossary which works perfect, I just changed the url and options in DATA. I’m also not getting any errors if I change the auth. code.
<?php
$text = 'Hi there';
$source_lang = "en";
$target_lang = "de";
$glossary_id = "";
$tag_handling = "xml";
$ignore_tags = "x";
$formality = "";
$url = "https://api.deepl.com/v2/translate";
$authKey = "hidden";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$headers = array(
"Authorization: DeepL-Auth-Key .$authKey",
"Content-Type: application/json",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$data = <<<DATA
text=$text&source_lang=$source_lang&target_lang=$target_lang&tag_handling=$tag_handling&ignore_tags=$ignore_tags&formality=$formality&glossary=$glossary_id
DATA;
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
//for debug only!
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$resp = curl_exec($curl);
// Check for errors and display the error message
if($errno = curl_errno($curl)) {
$error_message = curl_strerror($errno);
echo "cURL error ({$errno}):n {$error_message}";
}
curl_close($curl);
var_dump($resp);
?>
I’m not getting any errors.