Baby-Markt/deepl-php-lib

Getting 403 although the API key is correct

iec989 opened this issue · 2 comments

I'm using the free version of deepl and I setup everything as per the instructions, but I'm getting the following error:

The Response seems to not be valid JSON. {"userId":2,"exception":"[object] (BabyMarkt\\DeepL\\DeepLException(code: 403)

When using CURL directly with the same API key, it works correctly.

I've tried the below and didn't work:

  • $deepl = new DeepL('KEY');
  • $deepl = new DeepL('KEY','api-free.deepl.com');
  • $deepl = new DeepL('KEY','api-free.deepl.com/v2/translate');

Then I do deepl->translate($text, \App::getLocale(), $lang) and get the 403

Would you know what could be happning?

VimS commented

Hey iec989,
try $deepl = new DeepL('KEY',2,'api-free.deepl.com');

public function __construct($authKey, $apiVersion = 2, $host = 'api.deepl.com')

As you can see here the constructor uses 3 Parameters:

  1. Your API Key
  2. The API-Version you want to use, which should be 2
  3. and then the host off the DeepL-Api

Hope this helps.

VimS commented

@iec989 Do you need further assistance ?