Using guzzle in laravel 5.8 to make external API requests in my app. When I perform a request from a controller it works fine.
How ever when using the same code in a Job which I dispatch in a controller, I dont get the same results, I get an incorrect url.
Tried using a variety of url and utf8 encoding/decoding
$name = 'Cheeríos';
$this->httpClient->get("$baseUri/" . strtolower($name) . "/info")->getBody();
actual results of url, which leads to a 404 because its removed the í from the name
example.com/user/cheer%E3%ADos/info
expected
example.com/user/cheer%C3%ADos/info
or
example.com/user/cheeríos/info
在strtolower()之前的字符串上使用rawurlencode()解决了该问题。
$this->httpClient->get("$baseUri/" . strtolower(rawurlencode($name)) . "/info")->getBody();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.