PHP Classes

Using command line and no OpenSSL ?

Recommend this page to a friend!

      PHP HTTP protocol client  >  All threads  >  Using command line and no OpenSSL ?  >  (Un) Subscribe thread alerts  
Subject:Using command line and no OpenSSL ?
Summary:?
Messages:4
Author:vMyth
Date:2009-02-25 17:35:58
Update:2009-02-26 20:23:45
 

  1. Using command line and no OpenSSL ?   Reply   Report abuse  
Picture of vMyth vMyth - 2009-02-25 17:35:58
<?
set_include_path(getcwd());

class GetHTML {
private $___http;

public function __construct() {
require('http.php');
set_time_limit(0);
$this->___http = new http_class;
$this->___http->timeout = 0;
$this->___http->data_timeout = 0;
$this->___http->debug = 0;
$this->___http->html_debug = 1;
}

public function get_html($url) {
$error = $this->___http->GetRequestArguments($url,$arguments);
$arguments['RequestMethod'] = 'GET';
$error = $this->___http->Open($arguments);

if(empty($error)) {
$error = $this->___http->SendRequest($arguments);
if(empty($error)) {
$headers = array();
$error = $this->___http->ReadReplyHeaders($headers);
if(empty($error)) {
for(;;) {
$error = $this->___http->ReadReplyBody($data, 1048576);
if(!empty($error) || strlen($data) == 0) break;
$html.=$data;
}
}
}
$this->___http->Close();
}

if(!empty($error)) return $error;
return $html;
}
}

$GetHTML = new GetHTML;
echo $GetHTML->get_html('https://msp.f-secure.com/web-test/common/test.html');
?>

Here is my code. I tested it in my browser and it worked fine. But when I used it by command line :

C:\xampp\php>php.exe C:\xampp\htdocs\php.php

And what I got was :
establishing SSL connections requires the OpenSSL extension enabled

My OpenSSL is enabled by default in PHP configuration file. I have searched but I can't find any answer to this problem. Can you help me please ?

  2. Re: Using command line and no OpenSSL ?   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-02-26 02:16:54 - In reply to message 1 from vMyth
Try php -i to see if PHP CLI version has the OpenSSL enabled. Maybe that version uses a different php.ini file that does include the necessary configuration lines to load the OpenSSL extension.

  3. Re: Using command line and no OpenSSL ?   Reply   Report abuse  
Picture of vMyth vMyth - 2009-02-26 09:32:48 - In reply to message 2 from Manuel Lemos
OK, sorry but it was my fault for not enabling OpenSSL in the php\php.ini. I have other questions, if I use cURL by setting the $prefer_curl to "1", then could I use SOCKS v4 ? And what is the requirement for the PHP to use SOCKS servers ?

  4. Re: Using command line and no OpenSSL ?   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-02-26 20:23:45 - In reply to message 3 from vMyth
The class already supports SOCKS, there is no need to use Curl. Just set the variables $socks_host_name and $socks_version .