Baby-Markt/deepl-php-lib

[Bug] Cannot create a Glossary after deleting another one

MolloKhan opened this issue · 2 comments

Hi, I just found a bug when trying to create a custom "update" operation for my glossaries. Since the API does not support an update operation what I did as a workaround was to delete first the Glossary and then recreate it with the new entries list.
The problem is that this library has a bug when you make a POST request after a DELETE request, I get the error The Response seems to not be valid JSON.

The BabyMarkt\DeepL\Client needs a way to reset its $curl property after any of those requests. I added these lines just before handling the response and it suddenly worked

        if ($this->curl && is_resource($this->curl)) {
            curl_close($this->curl);
        }

        $this->curl = curl_init();
        curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, 1);
VimS commented

Could you create a pull request please?
Without a sample-usage it is difficult to tell where the Bug is.

I just did here #44