0

I tried accessing a api using curl and it getting output in non https site, but I update this code in https certify site but not working. I have tried code as like below it is working in non-https site.

$url = "http://45.116.113.98:8081/WebAP1/api/SchemeMast/1/40/WEBDTG100-/45/-/Prabakaran/S/-/4-44,pillaiyar%20kovil%20street,ko.thoppu%20vill,nochalu/-/Villupuram/Villupuram/Tamil%20Nadu/India/604201/9787162221/9787162221/0.000/100.00/2017-12-21/C"; 
$headers = array();
$headers[] = 'Accept: image/gif, image/x-bitmap, image/jpeg, image/pjpeg'; 
$headers[] = 'Connection: Keep-Alive'; 
$headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8'; 
$user_agent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0)'; 
$process = curl_init($url); 
curl_setopt($process, CURLOPT_HTTPHEADER, $headers);
curl_setopt($process, CURLOPT_HEADER, 0); 
curl_setopt($process, CURLOPT_USERAGENT, $user_agent); 
curl_setopt($process, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1); 
$return = curl_exec($process);
curl_close($process);

And also tried in this way also,

        curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
        curl_setopt( $ch, CURLOPT_HTTPGET, 1 );
        curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
        curl_setopt( $ch, CURLOPT_FOLLOWLOCATION , 1 );
        curl_setopt( $ch, CURLOPT_URL, $url );
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

But both are not working in my https site

cn007b
  • 16,596
  • 7
  • 59
  • 74
Vinoth Kumar
  • 489
  • 3
  • 17
  • 45
  • Possible duplicate of [PHP CURL & HTTPS](https://stackoverflow.com/questions/4372710/php-curl-https) – IcedAnt Dec 21 '17 at 12:01
  • `curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);` only this could be enough for that.. But i tried to access your url, but is not working. Your curl script seems to be good. – Andrei Todorut Dec 21 '17 at 12:03
  • But not working in my https site, same thing working in my http site – Vinoth Kumar Dec 21 '17 at 12:09

1 Answers1

0

Your problem is described here:

curl -i https://45.116.113.98:8081
curl: (35) error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

and here

enter image description here

It means that HTTPS protocol is not supported,
maybe because site not configured to support HTTPS
or you're using wrong port (by default: http -> 80, https -> 443).

cn007b
  • 16,596
  • 7
  • 59
  • 74
  • My site name is https://www.srisaravanajewellers.in. I'm calling api http://45.116.113.98:8081 – Vinoth Kumar Dec 21 '17 at 12:21
  • In this case, it means that api 45.116.113.98:8081 doesn't support https protocol! You have to communicate with support team and ask them to configure https. – cn007b Dec 21 '17 at 12:28
  • But please don't use `curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);` you may end up with situation when you'll send secure information over insecure connection. – cn007b Dec 21 '17 at 12:30
  • Btw this error may occur in case you're using wrong port. – cn007b Dec 21 '17 at 12:34