-3

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.

Magiranu
  • 299
  • 4
  • 27

2 Answers2

1

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.

RWC
  • 4,697
  • 2
  • 22
  • 29
  • Thank you and you're absolutly right. It hasn't anything to do with PHP but rather with Httpful. I updated my question accordingly. – Magiranu Aug 16 '17 at 18:06
  • 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! – Magiranu Aug 16 '17 at 19:55
0
ini_set('max_execution_time', 500);

in your script,place this one on the top,its increase the execution time of your code.

gaurav
  • 657
  • 4
  • 11
  • This does not answer the question "How to add double Backslash into a String in PHP?". – RWC Aug 16 '17 at 12:03
  • The problem is because of max execution time which he has mentioned above and he is using right syntax for adding backslash. – gaurav Aug 16 '17 at 12:07
  • No that is not his problem and your answer doesn't solve his issue. He asked two questions. 1. "How to add double Backslash into a String in PHP?" and 2 "Why is escaping the backslash not working in this case?". You do not provide an answer to these questions. – RWC Aug 16 '17 at 12:15