本文介绍了如何在使用Kohana请求时设置CURL选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用Request类获取外部资源,但无法找出如何设置更多默认curl选项。

Trying to use the Request class to get an external resources, but can't figure out how to set more default curl options.

我得到的数据:

$data = Request::factory($url)->execute()->body();

我想添加CURL选项是一个简单的问题, /config/curl.php 到我的应用程序config文件夹,然后设置选项(我认为他们将被合并?)。

I figured adding CURL options was a simple matter of making a copy of system/config/curl.php into my application config folder and then setting the options there (I assume they will be merged?).

但是这些选项似乎没有使用?试图在所有选项应该已经设置之后在 Kohana_Request_Client_Curl 中执行 var_dump ,但是我只能找到在这个方法中直接设置,这是有意义的,因为我似乎找不到这些选项实际上是从配置文件中获取...

But those options don't seem to be used at all? Tried to do a var_dump in Kohana_Request_Client_Curl after all the options should've been set, but I can only find the ones set directly there in that method, which makes sense as I can't seem to find anywhere these options are actually fetched from the config file...

我在做什么

推荐答案

这里有更详细的示例:

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

$request->client()->options(array(
    CURLOPT_SSL_VERIFYPEER => FALSE
));

这篇关于如何在使用Kohana请求时设置CURL选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 14:17
查看更多