我一直使用 cURL 来处理这类事情,但这篇文章让我想到我可以使用 Kohana 3 中的 Request 对象轻松请求另一个页面。
$url = 'http://www.example.com';
$update = Request::factory($url);
$update->method = 'POST';
$update->post = array(
'key' => 'value'
);
$update->execute();
echo $update->response;
但是我得到了错误
Accessing static property Request::$method as non static
由此我可以假设这意味着方法方法是静态的,但这对我没有多大帮助。我还复制并粘贴了该文章中的示例,它引发了同样的错误。
基本上,我正在尝试发布到外部服务器上的新页面,并以 Kohana 方式进行。
那么,我这样做是否正确,还是应该只使用 cURL(或file_get_contents()
上下文)?