0

Following: https://kohanaframework.org/3.2/guide/kohana/requests

I have this code:

$request = Request::factory($url);

$request
    ->client()
    ->options(array(
    CURLOPT_SSL_VERIFYPEER => FALSE,
    CURLOPT_USERPWD => 'test' . ':' . 'token'
    ));

$response = $request->execute();

$response = json_decode($response);

if(is_array($response) && isset($response['product_feed_url']))
{
    echo "Ok Access";
}else{
    echo "No Access";
}

Inside a my controller function action_getsettings().

I am using the Request::factory() instead of manual curl and it all works fine, but the problem is that the response of the $request does not get stoerd in the $response - it just outputs directly and exits the controller (it doesnt go to the json_decode and if statement)

Also tried $response = $request->execute()->body(); but it still just outputs as if i did return $response;

Why does this happen?

Karem
  • 17,615
  • 72
  • 178
  • 278
  • Where are you placing this code? Inside a controller, this triggers an error for me. ErrorException [ Fatal Error ]: Call to undefined method Request_Client_Internal::options() – mrBrown Sep 28 '15 at 11:36

1 Answers1

0
  1. Where are you placing this code? Inside an controller, this triggers an error for me.: ErrorException [ Fatal Error ]: Call to undefined method Request_Client_Internal::options().
  2. Are you making a call to an internal uri or an external? Internal works perfectly fine for me.

`

$uri = 'controller/action';
$request = Request::factory($uri);
$request->execute();
mrBrown
  • 153
  • 1
  • 10
  • I am making a external request. API request. Inside a controller yes, no errors for options() that works fine – Karem Sep 28 '15 at 14:26