【发布时间】:2014-05-07 23:02:02
【问题描述】:
我正在通过 Kohana 3.2 发出 cURL 请求,但是当它尝试访问 CURLOPT_POST 常量时出现以下错误:
Use of undefined constant CURLOPT_POST - assumed 'CURLOPT_POST'
来自 Kohana 3.2 system/classes/kohana/request/client/curl.php
public function _set_curl_request_method(Request $request, array $options)
{
switch ($request->method()) {
case Request::POST:
$options[CURLOPT_POST] = TRUE;
break;
case Request::PUT:
$options[CURLOPT_PUT] = TRUE;
break;
default:
$options[CURLOPT_CUSTOMREQUEST] = $request->method();
break;
}
return $options;
}
我的申请代码:
$request = Request::factory($uri);
$request->query('key', $key);
$request->post($params);
$request->method(Request::POST);
// fails here
$response = $request->execute();
我已经使用以下方法测试了 curl 作为扩展是活动的:
if (in_array ('curl', get_loaded_extensions()))
{
echo '1';
}
else
{
echo '0';
}
这里有什么问题?我使用的是 Windows 7、PHP 5.4.12 和 Apache 2.4。
【问题讨论】:
-
你能在你实际使用
CURLOPT_POST的地方展示这段代码吗? -
将代码添加到我的帖子中
-
您是否已经对脚本中的任何 curl 函数进行了实际调用?如果 curl 扩展不可用,可以使用
undefined function curl_....让 php 摆脱困境?如果不是(或不确定),最好通过 phpinfo()、extension_loaded('curl')、... 仔细检查 -
不,你能在你提出实际请求的地方显示代码吗?您发布的代码是来自 Kohana 库的 sn-p。您是通过请求工厂发出请求吗?如果是这样,如何?显示那部分代码..例如
$request = Request::factory($url)->method('POST')->post('key', 'value'); -
我知道这还为时过早,但这难道不是来自未引用数组键的预期行为吗?
标签: php apache curl wamp kohana