Skip to content

Commit a12ff84

Browse files
authored
Merge pull request #114 from Dala0/fix_400_errors
Fixes 400 BadRequest Errors For Old 3.2 Branch
2 parents 2ad0de0 + 5e31e97 commit a12ff84

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/Stichoza/GoogleTranslate/TranslateClient.php

+3-9
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class TranslateClient
6767
* @var array URL Parameters
6868
*/
6969
private $urlParams = [
70-
'client' => 't',
70+
'client' => 'webapp',
7171
'hl' => 'en',
7272
'dt' => 't',
7373
'sl' => null, // Source language
@@ -305,20 +305,14 @@ private function getResponse($data)
305305
'sl' => $this->sourceLanguage,
306306
'tl' => $this->targetLanguage,
307307
'tk' => $this->tokenProvider->generateToken($this->sourceLanguage, $this->targetLanguage, $tokenData),
308+
'q' => $tokenData
308309
]);
309310

310311
$queryUrl = preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', http_build_query($queryArray));
311312

312-
$queryBodyArray = [
313-
'q' => $data,
314-
];
315-
316-
$queryBodyEncoded = preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', http_build_query($queryBodyArray));
317-
318313
try {
319-
$response = $this->httpClient->post($this->urlBase, [
314+
$response = $this->httpClient->get($this->urlBase, [
320315
'query' => $queryUrl,
321-
'body' => $queryBodyEncoded,
322316
] + $this->httpOptions);
323317
} catch (GuzzleRequestException $e) {
324318
throw new ErrorException($e->getMessage());

0 commit comments

Comments
 (0)