2

I am trying to make an external request. I am following examples provided here in Kohana Docs.

Thing is, I am trying to do a GET with GET params. As soon as I provide a URL with GET params to the factory method, the params get stripped from the URL and placed in _get property of the Request object.

Here's how it looks on my side:

$request = Request::factory('http://www.example.com/api.php?param1=value1&param2=value2');
$response = $request->execute();

If I print_r the $request object I can see this (extract):

[_get:protected] => Array
    (
        [param1] => value1
        [param2] => value2
    )

But unfortunately it doesn't looks as if these get sent when executing the request.

Why might this be?

random
  • 9,774
  • 10
  • 66
  • 83
Michal M
  • 9,322
  • 8
  • 47
  • 63

1 Answers1

6

Use the query() method to set GET data.

$request = Request::factory('http://www.example.com/api.php')->query(array('param1' => 'value1', 'param2' => 'value2'));
$response = $request->execute();
Thorsten
  • 5,634
  • 6
  • 35
  • 33