我正在尝试通过 curl 使用我的网络服务:
public function getImages($time) {
$url = $this->rest_url['employees'] . "?action=getAllNewPhotos&accessKey=" . $this->rest_key['employees'] . "&lastcheck=" . $time;
$data = $this->CI->curl->simple_get($url);
if ($data) {
return json_decode($data);
} else {
return null;
}
}
但它一直给我以下错误:
致命错误:在非对象上调用成员函数 simple_get()
这是为什么?
此外,如果我在自动加载中添加 curl 它会说:
无法加载请求的类:curl
但是,如果我通过以下代码运行我的代码,则没有问题:
$url = $this->rest_url['employees'] . "?action=getAllNewPhotos&accessKey=" . $this->rest_key['employees'] . "&lastcheck=" . $time;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
if ($data) {
return json_decode($data);
} else {
return null;
}
我只是好奇为什么我的第一种方法不起作用!
如果您需要更多说明,请告诉我!
谢谢