我正在向RIPE的API发出GET
请求,但未获得HTTP状态代码或curl_getinfo($i)
中的任何内容。
$i=curl_init();
curl_setopt_array($i,
array(
CURLOPT_URL=>'https://rest.db.ripe.net/search.json?query-string='.$this->storage->ip->current,
CURLOPT_HTTPHEADER=>array('Accept: application/json'),
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_ENCODING=>'UTF-8'
)
);
我做错什么了吗?
array(26) {
["url"]=>
string(61) "https://rest.db.ripe.net/search.json?query-string=XX.XXX.XXX.37"
["content_type"]=>
NULL
["http_code"]=>
int(0)
["header_size"]=>
int(0)
["request_size"]=>
int(0)
["filetime"]=>
int(0)
["ssl_verify_result"]=>
int(0)
["redirect_count"]=>
int(0)
["total_time"]=>
float(0)
["namelookup_time"]=>
float(0)
["connect_time"]=>
float(0)
["pretransfer_time"]=>
float(0)
["size_upload"]=>
float(0)
["size_download"]=>
float(0)
["speed_download"]=>
float(0)
["speed_upload"]=>
float(0)
["download_content_length"]=>
float(-1)
["upload_content_length"]=>
float(-1)
["starttransfer_time"]=>
float(0)
["redirect_time"]=>
float(0)
["redirect_url"]=>
string(0) ""
["primary_ip"]=>
string(0) ""
["certinfo"]=>
array(0) {
}
["primary_port"]=>
int(0)
["local_ip"]=>
string(0) ""
["local_port"]=>
int(0)
}
答案 0 :(得分:0)
您应该在curl_setopt_array()之后使用curl_exec()和curl_close(),添加以下内容:
// grab URL and pass it to the browser
curl_exec($i);
// close cURL resource, and free up system resources
curl_close($i);