nategood / httpful

A Chainable, REST Friendly, PHP HTTP Client. A sane alternative to cURL.
MIT License
1.74k stars 298 forks source link

How can I send an URI with " " or \\ in it? #261

Closed Magiranu closed 7 years ago

Magiranu commented 7 years ago

Hi @all

The idea is to send terms like bob & \\apples to a server. I get this error:

Fatal error: Maximum execution time of 30 seconds exceeded

Here is my function:

public function index($request, $response)
{     
    $uri = 'http://example.org/folder?key=["bob", "\\apples"];
    $content = \Httpful\Request::get($uri)->send();
    return $content;
}

The mysterious thing is, that it works with only one term (?key="bob") but with two it doesn't. When I put the URL into my browser, I get back the proper results (JSON response) with one and with two terms. So at the end it works but Httpful does something I don't know of yet. Would you please be so kind and shed some light on it? :-)

Magiranu commented 7 years ago

Alright, I got this figured out at the end. I needed to encode the unicode text like this:

[--> %5B ] --> %5D " -->%22 , --> %2C

Hope this will help anyone in the future. Thanks guys!