Search code examples
httpful

How to give Httpful a String with double quotes in it?


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

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

As user RWC pointed out, it seems to be the library which causes this error.

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.


Solution

  • The question you are asking is very specific for the libary you are using, Httpful, and is not a pure PHP question.

    This is a valid URL:

    https://www.google.com/search?q=\

    and so 'http://server/search?key=\' is a valid URL.

    If the following command does not work

    Request::get($uri)->send() 
    

    you have to blame the library (Httpful). You provided a valid URL, so in my opinion if the libary was well written, it should work. So you have to do something to make it work. What? For that you have to read the documentation of the library.

    Good to hear that you find a solution, but is has nothing to do with normal PHP.