2. In order to install CURL I have to upgrade my openssl rpm, even
though I'm runing a version of linux that's only like 3 months old
(fedora c2 stable), because curl needs libcrypto.so.4.
3. In order to install libcrypto.so.4 I have to upgrade my openssl
(took me forever to figure that out).
4. Upgrading my openssl rpm pretty much requires re-installing just
about everything in my entire linux distro that's useful, because half
of everything uses libcrypto.
Ergo:
To make php make an https request, you either have to do the entire
https request yourself starting with an tcp connection, or you can use
curl which means (for nearly everyone), re-installing half the
software on your server. http://tinyurl.com/6ph53
And with perl all you do is download one module from cpan. Oh no,
wait, it already comes with the perl distro.
Anyone correct me or do I have that all right?
You can't expect that the CD's of Fedora upgrade themselves. I always
use minicd's (like ArchLinux Base or FreeBSD miniinst) so only the base
system is installed. Then I let it install the rest via a package
manager (pacman or ports), so I don't have to search for rpm's (pacman
-Sy php or cd /usr/ports/www/mod_php && make install clean does the
trick). With the FreeBSD ports you even get a nice screen asking you
which extentions for PHP you want to have installed and it will
automatically install them and their dependencies.
--
Pieter Nobels
> 1. In order to make an http (or https) request with PHP, I need to
> recompile php with cURL.
>
No; I use file(..) for GET and my own protocol implementation for POST via
HTTP. It's possible to route these through stunnel if you need SSL but
don't want to do the curl thing.
> 2. In order to install CURL I have to upgrade my openssl rpm, even
> though I'm runing a version of linux that's only like 3 months old
> (fedora c2 stable), because curl needs libcrypto.so.4.
>
Given it's nature, keeping SSL up to date is pretty much a 'must'.
> 4. Upgrading my openssl rpm pretty much requires re-installing just
> about everything in my entire linux distro that's useful, because half
> of everything uses libcrypto.
>
You don't *have* to upgrade it just install the alternative version
alongside, or use an older version of libcurl. Note that this would be
rather a dumb thing to do.
Can't comment on how to do it with Perl but I suspect it might amount to the
silly suggestions in the previous paragraph.
HTH
C.
> 1. In order to make an http (or https) request with PHP, I need to
> recompile php with cURL.
I believe this is correct, unless you can find a pre-packaged PHP that
already has PHP/CURL[*] support built-in. Such packages exist for
several Linux distributions at least.
> 2. In order to install CURL I have to upgrade my openssl rpm
Hold it. If you can build PHP from source, why can't you build curl
from source too? If you do, you won't get any curl package that
depends on a OpenSSL version you don't have.
> though I'm runing a version of linux that's only like 3 months old
> (fedora c2 stable), because curl needs libcrypto.so.4.
Not entirely true. libcurl (which is the library PHP/CURL uses) is
built to use OpenSSL. If someone packaged a libcurl to require
libcrypto.so.4 then so be it, that packaged libcurl requires it. That
doesn't mean that libcurl itself requires that particular libcrypto
version.
[*] = note that the project curl provides curl the command line tool
and the libcurl library. The curl PHP offers is better called PHP/CURL
or mod_curl to more clearly differentiate it from the other curls.
No you don't. Consider this simple function:
function HTTP_GET($host='localhost', $path='/', $port=80, $timeout=10) {
// This function takes up to four optional arguments:
//
// $host (defaults to 'localhost') -- the name of target HTTP host,
// $path (defaults to '/') -- the target path
// $port (defaults to 80) -- the target port number
// $timeout (defaults to 10) -- maximum allowed waiting time
//
// On success, the function returns an associative array of two
// string fields: 'headers' (HTTP headers returned by the target
// host) and 'content' (the body of the HTTP response). On failure,
// the function returns FALSE.
$headers = '';
$content = '';
$flag = false;
$fp = fsockopen($host, $port, $errno, $errstr, $timeout);
if (!$fp) {
echo "Error $errno: $errstring. \r\n";
return false;
} else {
fwrite($fp, "GET $path HTTP/1.0\r\n" .
"Host: $host\r\n\r\n");
while (!feof($fp)) {
$line = fgets($fp, 10240);
if ($flag) {
$content .= $line;
} else {
$headers .= $line;
if (strlen(trim($line)) == 0) {
$flag = true;
}
}
}
fclose($fp);
return array('headers' => $headers, 'content' => $content);
}
}
Example of usage:
$host = 'www.yourhost.com'; // Assume we want to retrieve a file
$path = '/path/to/file.htm'; // http://www.yourhost.ru/path/to/file.htm
if ($response = HTTP_GET($host, $path)) {
extract($response);
}
POST requests are not much more difficult...
Cheers,
NC
Well, on Windows you just unzip the binary distribution into C:\PHP and
everything works more or less.
If you are going to use Linux, then don't complain about having to compile
stuff.
> dter...@hotmail.com (mrbog) wrote in message
> news:<cbd4bb52.04082...@posting.google.com>...
>>
>> In order to make an http (or https) request with PHP, I need to
>> recompile php with cURL.
>
> No you don't. Consider this simple function:
[snip]
The fopen(), include(), file(), file_get_contents() etc functions support
http urls as the filename, so you don't need to open a socket connection.
You can do it like this:
$webpage = file_get_contents('http://www.domain.com/foo.html');
(Note that you need PHP 4.3.0 or higher for file_get_contents(). Use fopen()
etc for earlier versions).
This works for http requests but you still need the ssl libraries installed
to make an https request.
Check out the following for more info
http://www.php.net/manual/en/features.remote-files.php
and note in particular "you can use HTTP and FTP URLs with most of the
functions that take a filename as a parameter."
--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Generally speaking, you are right. But, as we all know, the devil
is in details. In particular, one can encounter one or both of the
following errors when trying to access remote files via file system
functions:
Warning: file([URL]) - Success in file.php on line XXX
Warning: fopen([URL], "r") - Undefined error: 0
It's been known to happen even when working with Amazon Web Services
and Google.
In addition, file system functions do not allow you to capture HTTP
headers returned by the remote server, and those may be important,
especially if you are trying to implement data retrieval from a
remote site with a cookie-based authentication system.
Cheers,
NC
When I use perl and linux, I don't have to recompile openssl. You
still sure I shouldn't complain?
Or maybe PHP is a mainly-microsoft thing, eh? wink wink.