Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getResponse() error while trying to send query with PHP_EOL #85

Closed
marbastm opened this issue Jul 27, 2017 · 2 comments
Closed

getResponse() error while trying to send query with PHP_EOL #85

marbastm opened this issue Jul 27, 2017 · 2 comments

Comments

@marbastm
Copy link

Hi, I' am trying to send PHP_EOL (\n) symbols within my query, but I get the following error (403 Forbidden):
https://pastebin.com/pR9JEbKP

To do so I use in the input ($data) text blocks with three numbes like <666> and in TranslateClient.php in section private function getResponse($data) I use the following replacement:
$data = str_replace('<888>', PHP_EOL, $data); right before $queryArray = array_merge[..]

In the meantime, I' am able to decode the $queryBodyEncoded query with http://www.url-encode-decode.com/ and it shows that my query syntax (if it's a thing) is right (comparing to query without PHP_EOL).

So I assume that it's either Google don't like query with encoded PHP_EOL or I' am doing smth wrong.
Please help me.

@marbastm
Copy link
Author

I logged $queryBodyEncoded and used its result in browser and got the translation so it seems that Guzzle is returning error.

@marbastm
Copy link
Author

It seems that just rearragement of $data = str_replace('<888>', PHP_EOL, $data); and $tokenData = is_array($data) ? implode('', $data) : $data; solved it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant