-1

i try to call this api but there was an error

cURL Error #:couldn't connect to host

i try this code

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

there was an issue with proxy server...?

how can i solve it in php

Arav
  • 23
  • 1
  • 8
  • Possible duplicate of [How to resolve cURL Error (7): couldn't connect to host?](https://stackoverflow.com/questions/9922562/how-to-resolve-curl-error-7-couldnt-connect-to-host) – AZinkey Oct 17 '17 at 06:50

1 Answers1

0

It may be network issue or something, Curl is perfect for reading urls i tried with your code and it giving perfect result.

Check this,

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

Attached Output,

Ritesh Khatri
  • 1,253
  • 13
  • 29