我尝试调用此api,但出现错误
cURL Error #:couldn't connect to host
我试试这段代码
<?php
$url = 'http://134.255.218.101:3002/ext/getaddress/GeHSBSKg5kav6vy6neQB5XsZ29zsNRyqeb';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://134.255.218.101:3002/ext/getaddress/GeHSBSKg5kav6vy6neQB5XsZ29zsNRyqeb',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
"accept: application/json",
"cache-control: no-cache",
"content-type: application/json"
),
));
echo $response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>
代理服务器存在问题......?
我怎样才能在php中解决它
答案 0 :(得分:0)
可能是网络问题或其他什么, Curl非常适合阅读我尝试使用您的代码的网址,它可以提供完美的结果。
检查一下,
<?php
$url [![enter image description here][1]][1]='http://134.255.218.101:3002/ext/getaddress/GeHSBSKg5kav6vy6neQB5XsZ29zsNR
yqeb';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => false,
CURLOPT_HTTPHEADER => array(
"accept: application/json",
"cache-control: no-cache",
"content-type: application/json"
),
));
echo $response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>
附加输出,