cURL Response is empty

I’ve got request from my client today to change in app from google cloud to deepl api for translations. So I found package for laravel "babymarkt/deepl-php-lib": "^2.0"

my test code is like this:

$authKey = env('TRANSLATE_CLIENT_KEY');
$deepl   = new DeepL($authKey);
$translatedText = $deepl->translate('Hello world', 'en', 'de');

and I’m getting error The Response seems to not be valid JSON.


Actually when I try to dd($response) I get empty string ""

I’m not familiar with cURL. So anyone has a suggestion or any idea why is this happening?

Here is also a screenshot of $this->curl

This is from package:

protected function request($url, $body = '')
    curl_setopt($this->curl, CURLOPT_POST, true);
    curl_setopt($this->curl, CURLOPT_URL, $url);
    curl_setopt($this->curl, CURLOPT_POSTFIELDS, $body);
    curl_setopt($this->curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));

    $response = curl_exec($this->curl);

    if (curl_errno($this->curl)) {
        throw new DeepLException('There was a cURL Request Error.');
    $httpCode      = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);
    $responseArray = json_decode($response, true);

    if ($httpCode != 200 && is_array($responseArray) && array_key_exists('message', $responseArray)) {
        throw new DeepLException($responseArray['message'], $httpCode);

    if (false === is_array($responseArray)) {
        throw new DeepLException('The Response seems to not be valid JSON.', $httpCode);

    return $responseArray;


In the curl Resource you’ll see the http_code is set to 403. Looking at the documentation on it shows that if you receive that you failed to provide an auth_key parameter. Work backwards to see if:

$authKey = env('TRANSLATE_CLIENT_KEY');

Is behaving correctly.

Leave a Reply

Your email address will not be published. Required fields are marked *