【发布时间】:2015-09-27 19:48:28
【问题描述】:
关注:https://kohanaframework.org/3.2/guide/kohana/requests
我有这个代码:
$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";
}
在我的控制器函数 action_getsettings() 中。
我正在使用 Request::factory() 而不是手动 curl 并且一切正常,但问题是 $request 的响应没有在 $response 中存储 - 它只是直接输出并退出控制器(它不去 json_decode 和 if 语句)
也尝试了$response = $request->execute()->body();,但它仍然像我一样输出return $response;
为什么会这样?
【问题讨论】:
-
您将此代码放在哪里?在控制器内部,这会触发我的错误。 ErrorException [致命错误]:调用未定义的方法 Request_Client_Internal::options()
标签: curl request kohana kohana-3.2