ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

Is there a way to read a SSL/HTTPS page using cURL?

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.

user-image
تم إضافة السؤال من قبل Muhammad Majid Saleem , Senior PHP Developer / Project Manager , SwaamTech
تاريخ النشر: 2014/01/29
عبدالرزاق رحمون
من قبل عبدالرزاق رحمون , IT engineer , Ministry of Education

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

Nouphal Muhammed
من قبل Nouphal Muhammed , Senior Web Developer , Planet Green Solutions

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);

}

Mahmoud Mamdouh
من قبل Mahmoud Mamdouh , Linux System Administrator (Remote position) , 2X4.ru

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);

المزيد من الأسئلة المماثلة