2017-10-17 117 views
-1

主辦我嘗試調用這個API,但有一個錯誤捲曲錯誤#:無法連接在PHP

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

的可能的複製[如何解決捲曲錯誤(7):無法連接到主機?(https://stackoverflow.com/問題/ 9922562 /如何解決curl-error-7-couldnt-connect-to-host) – AZinkey

回答

0

這可能是網絡問題,或者什麼的, 捲曲非常適合閱讀的網址我想與您的代碼,並給予它完美的結果。

檢查這一點,

<?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; 
} 
?> 

附加輸出,

+0

@enter image description here ......? – Arav

+0

它只是一個輸出頁面ss。 – Rits

+0

它可能是一個代理問題,你可以通過代理或做一些代理更改來連接你的代理。 – Rits