Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.
I am trying to read content from https://zipcodedownload.com/Documentation/WebService/index.html using their provided APIs. But I am unable to read content using cURL because it is on SSL.
with codeigniter
<?php if (!defined('BASEPATH')) exit('No direct script access allowed.');
class Example extends Controller {
function __construct()
{
parent::Controller();
}
function index()
{
// load curl library
$this->load->library('curl');
// your link
$url='https://zipcodedownload.com/Documentation/WebService/index.html'; $this->curl->option('connecttimeout',);
// For SSL Sites. Check whether the Host Name you are connecting to is valid $this->curl->option('SSL_VERIFYPEER',false);
// Ensure that the server is the server you mean to be talking to $this->curl->option('SSL_VERIFYHOST',false);
// Defines the SSL Version to be Used $this->curl->option('SSLVERSION',3);
$data=$this->curl->execute();
echo$data;
}
}
///////////////////
for more info try this
Try this:
$url = 'https://zipcodedownload.com/Documentation/WebService/index.html';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); // set url
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //SET SSL verification to false
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT5.1; en-US; rv:1.8.1.6) Gecko/ Firefox/2.0.0.6"); // set browser/user agent
curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'read_header'); // get header
curl_exec($ch);
function read_header($ch, $string) {
print "Received header: $string";
return strlen($string);
}
if the URL constant .. so you can download crt of that site at your host and then use it inside your code :
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,1); curl_setopt($ch, CURLOPT_CAINFO, '/path/to/site.crt');or if it is not , or there are huge amount of ssl sites .. you can disable ssl verify from :curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);