PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<crack_opendictcurl_close>
view the version of this page
Last updated: Thu, 21 Aug 2003

XII. CURL, Client URL Library Functions

Introduction

PHP supports libcurl, a library created by Daniel Stenberg, that allows you to connect and communicate to many different types of servers with many different types of protocols. libcurl currently supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols. libcurl also supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading (this can also be done with PHP's ftp extension), HTTP form based upload, proxies, cookies, and user+password authentication.

These functions have been added in PHP 4.0.2.

Requirements

In order to use the CURL functions you need to install the CURL package. PHP requires that you use CURL 7.0.2-beta or higher. PHP will not work with any version of CURL below version 7.0.2-beta. In PHP version 4.2.3, you will need CURL version 7.9.0 or higher. From PHP 4.3.0, you will need a CURL version that's 7.9.8 or higher. PHP 5.0.0 will most likely require a CURL version greater than 7.10.5

Installation

To use PHP's CURL support you must also compile PHP --with-curl[=DIR] where DIR is the location of the directory containing the lib and include directories. In the "include" directory there should be a folder named "curl" which should contain the easy.h and curl.h files. There should be a file named libcurl.a located in the "lib" directory. Beginning with PHP 4.3.0 you can configure PHP to use CURL for url streams --with-curlwrappers.

Note to Win32 Users: In order to enable this module on a Windows environment, you must copy libeay32.dll and ssleay32.dll from the DLL folder of the PHP/Win32 binary package to the SYSTEM32 folder of your Windows machine. (Ex: C:\WINNT\SYSTEM32 or C:\WINDOWS\SYSTEM32)

Predefined Constants

The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.

CURLOPT_PORT (integer)

CURLOPT_FILE (integer)

CURLOPT_INFILE (integer)

CURLOPT_INFILESIZE (integer)

CURLOPT_URL (integer)

CURLOPT_PROXY (integer)

CURLOPT_VERBOSE (integer)

CURLOPT_HEADER (integer)

CURLOPT_HTTPHEADER (integer)

CURLOPT_NOPROGRESS (integer)

CURLOPT_NOBODY (integer)

CURLOPT_FAILONERROR (integer)

CURLOPT_UPLOAD (integer)

CURLOPT_POST (integer)

CURLOPT_FTPLISTONLY (integer)

CURLOPT_FTPAPPEND (integer)

CURLOPT_NETRC (integer)

CURLOPT_FOLLOWLOCATION (integer)

CURLOPT_FTPASCII (integer)

CURLOPT_PUT (integer)

CURLOPT_MUTE (integer)

CURLOPT_USERPWD (integer)

CURLOPT_PROXYUSERPWD (integer)

CURLOPT_RANGE (integer)

CURLOPT_TIMEOUT (integer)

CURLOPT_POSTFIELDS (integer)

CURLOPT_REFERER (integer)

CURLOPT_USERAGENT (integer)

CURLOPT_FTPPORT (integer)

CURLOPT_LOW_SPEED_LIMIT (integer)

CURLOPT_LOW_SPEED_TIME (integer)

CURLOPT_RESUME_FROM (integer)

CURLOPT_COOKIE (integer)

CURLOPT_SSLCERT (integer)

CURLOPT_SSLCERTPASSWD (integer)

CURLOPT_WRITEHEADER (integer)

CURLOPT_SSL_VERIFYHOST (integer)

CURLOPT_COOKIEFILE (integer)

CURLOPT_SSLVERSION (integer)

CURLOPT_TIMECONDITION (integer)

CURLOPT_TIMEVALUE (integer)

CURLOPT_CUSTOMREQUEST (integer)

CURLOPT_STDERR (integer)

CURLOPT_TRANSFERTEXT (integer)

CURLOPT_RETURNTRANSFER (integer)

CURLOPT_QUOTE (integer)

CURLOPT_POSTQUOTE (integer)

CURLOPT_INTERFACE (integer)

CURLOPT_KRB4LEVEL (integer)

CURLOPT_HTTPPROXYTUNNEL (integer)

CURLOPT_FILETIME (integer)

CURLOPT_WRITEFUNCTION (integer)

CURLOPT_READFUNCTION (integer)

CURLOPT_PASSWDFUNCTION (integer)

CURLOPT_HEADERFUNCTION (integer)

CURLOPT_MAXREDIRS (integer)

CURLOPT_MAXCONNECTS (integer)

CURLOPT_CLOSEPOLICY (integer)

CURLOPT_FRESH_CONNECT (integer)

CURLOPT_FORBID_REUSE (integer)

CURLOPT_RANDOM_FILE (integer)

CURLOPT_EGDSOCKET (integer)

CURLOPT_CONNECTTIMEOUT (integer)

CURLOPT_SSL_VERIFYPEER (integer)

CURLOPT_CAINFO (integer)

CURLOPT_COOKIEJAR (integer)

CURLOPT_SSL_CIPHER_LIST (integer)

CURLOPT_BINARYTRANSFER (integer)

CURLCLOSEPOLICY_LEAST_RECENTLY_USED (integer)

CURLCLOSEPOLICY_LEAST_TRAFFIC (integer)

CURLCLOSEPOLICY_SLOWEST (integer)

CURLCLOSEPOLICY_CALLBACK (integer)

CURLCLOSEPOLICY_OLDEST (integer)

CURLINFO_EFFECTIVE_URL (integer)

CURLINFO_HTTP_CODE (integer)

CURLINFO_HEADER_SIZE (integer)

CURLINFO_REQUEST_SIZE (integer)

CURLINFO_TOTAL_TIME (integer)

CURLINFO_NAMELOOKUP_TIME (integer)

CURLINFO_CONNECT_TIME (integer)

CURLINFO_PRETRANSFER_TIME (integer)

CURLINFO_SIZE_UPLOAD (integer)

CURLINFO_SIZE_DOWNLOAD (integer)

CURLINFO_SPEED_DOWNLOAD (integer)

CURLINFO_SPEED_UPLOAD (integer)

CURLINFO_FILETIME (integer)

CURLINFO_SSL_VERIFYRESULT (integer)

CURLINFO_CONTENT_LENGTH_DOWNLOAD (integer)

CURLINFO_CONTENT_LENGTH_UPLOAD (integer)

CURLE_OK (integer)

CURLE_UNSUPPORTED_PROTOCOL (integer)

CURLE_FAILED_INIT (integer)

CURLE_URL_MALFORMAT (integer)

CURLE_URL_MALFORMAT_USER (integer)

CURLE_COULDNT_RESOLVE_PROXY (integer)

CURLE_COULDNT_RESOLVE_HOST (integer)

CURLE_COULDNT_CONNECT (integer)

CURLE_FTP_WEIRD_SERVER_REPLY (integer)

CURLE_FTP_ACCESS_DENIED (integer)

CURLE_FTP_USER_PASSWORD_INCORRECT (integer)

CURLE_FTP_WEIRD_PASS_REPLY (integer)

CURLE_FTP_WEIRD_USER_REPLY (integer)

CURLE_FTP_WEIRD_PASV_REPLY (integer)

CURLE_FTP_WEIRD_227_FORMAT (integer)

CURLE_FTP_CANT_GET_HOST (integer)

CURLE_FTP_CANT_RECONNECT (integer)

CURLE_FTP_COULDNT_SET_BINARY (integer)

CURLE_PARTIAL_FILE (integer)

CURLE_FTP_COULDNT_RETR_FILE (integer)

CURLE_FTP_WRITE_ERROR (integer)

CURLE_FTP_QUOTE_ERROR (integer)

CURLE_HTTP_NOT_FOUND (integer)

CURLE_WRITE_ERROR (integer)

CURLE_MALFORMAT_USER (integer)

CURLE_FTP_COULDNT_STOR_FILE (integer)

CURLE_READ_ERROR (integer)

CURLE_OUT_OF_MEMORY (integer)

CURLE_OPERATION_TIMEOUTED (integer)

CURLE_FTP_COULDNT_SET_ASCII (integer)

CURLE_FTP_PORT_FAILED (integer)

CURLE_FTP_COULDNT_USE_REST (integer)

CURLE_FTP_COULDNT_GET_SIZE (integer)

CURLE_HTTP_RANGE_ERROR (integer)

CURLE_HTTP_POST_ERROR (integer)

CURLE_SSL_CONNECT_ERROR (integer)

CURLE_FTP_BAD_DOWNLOAD_RESUME (integer)

CURLE_FILE_COULDNT_READ_FILE (integer)

CURLE_LDAP_CANNOT_BIND (integer)

CURLE_LDAP_SEARCH_FAILED (integer)

CURLE_LIBRARY_NOT_FOUND (integer)

CURLE_FUNCTION_NOT_FOUND (integer)

CURLE_ABORTED_BY_CALLBACK (integer)

CURLE_BAD_FUNCTION_ARGUMENT (integer)

CURLE_BAD_CALLING_ORDER (integer)

CURLE_HTTP_PORT_FAILED (integer)

CURLE_BAD_PASSWORD_ENTERED (integer)

CURLE_TOO_MANY_REDIRECTS (integer)

CURLE_UNKNOWN_TELNET_OPTION (integer)

CURLE_TELNET_OPTION_SYNTAX (integer)

CURLE_OBSOLETE (integer)

CURLE_SSL_PEER_CERTIFICATE (integer)

Examples

Once you've compiled PHP with CURL support, you can begin using the CURL functions. The basic idea behind the CURL functions is that you initialize a CURL session using the curl_init(), then you can set all your options for the transfer via the curl_setopt(), then you can execute the session with the curl_exec() and then you finish off your session using the curl_close(). Here is an example that uses the CURL functions to fetch the example.com homepage into a file:

Example 1. Using PHP's CURL module to fetch the example.com homepage

<?php

$ch = curl_init ("http://www.example.com/");
$fp = fopen ("example_homepage.txt", "w");

curl_setopt ($ch, CURLOPT_FILE, $fp);
curl_setopt ($ch, CURLOPT_HEADER, 0);

curl_exec ($ch);
curl_close ($ch);
fclose ($fp);
?>

Table of Contents
curl_close -- Close a CURL session
curl_errno -- Return the last error number
curl_error --  Return a string containing the last error for the current session
curl_exec -- Perform a CURL session
curl_getinfo --  Get information regarding a specific transfer
curl_init -- Initialize a CURL session
curl_multi_add_handle --  Add a normal cURL handle to a cURL multi handle
curl_multi_close --  Close a set of cURL handles
curl_multi_exec --  Run the sub-connections of the current cURL handle
curl_multi_getcontent --  Return the content of a cURL handle if CURLOPT_RETURNTRANSFER is set
curl_multi_info_read --  Get information about the current transfers
curl_multi_init --  Returns a new cURL multi handle
curl_multi_remove_handle --  Remove a multi handle from a set of cURL handles
curl_multi_select --  Get all the sockets associated with the cURL extension, which can then be "selected"
curl_setopt -- Set an option for a CURL transfer
curl_version -- Return the current CURL version


add a note add a note User Contributed Notes
CURL, Client URL Library Functions
rodneywa at yahoo dot com
24-Oct-2003 03:47
Here's how I was able to post arrays using Curl:

$array_of_vars[]="var1";
$array_of_vars[]="var2";
$array_of_vars[]="var3";
$array_of_vars[]="var4";

$submit_url = "http://www.example.com/reads_post.php";
$formvars["feild1"] = "feild1";

for ($i=0;$i<sizeof($array_of_vars);$i++)
    $formvars["array_of_vars[$i]"] = $dna[$i];

   
// init curl handle
$ch = curl_init($submit_url);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $formvars);

// perform post
$rr=curl_exec($ch);
echo $rr;
curl_close($ch);
da at canaan dot co dot il
08-Oct-2003 09:42
i had problems with receiving all of the data that was replied to me about a transaction, atlast after way too much time spent i found out that all i missed was:
curl_setopt($ch, CURLOPT_HEADER, 1);

hope it helped anyone
alwong at 123infosys dot com
21-Sep-2003 09:35
The following scripts show how to post form to a web server via https.  I modified rodrigo posting because it did not work for me on IIS5.
<?php
    $url 
= 'https://www.yourserver.com/yourrequest;
    $params = "name=your_name&email=youremail@mail.com";
    $user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_POST,1);
    curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
    curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);  // this line makes it work under https

    $result=curl_exec ($ch);
    curl_close ($ch);

    echo("Results: <br>".$result);
?>
rodrigo dot nakahodo at dhweb dot com dot br
19-Sep-2003 02:57
The script shows how to get a simple response of a SSL Server. Enjoy it!

<?php

    $defined_vars 
get_defined_vars();

   
$_url 'https://www.example.com.br';
   
$_VAR001 'nono';
   
$_VAR002 'nonono';

   
$params "VAR001=$_VAR001&VAR002=$_VAR002&";

   
$ch curl_init();
   
curl_setopt($chCURLOPT_POST,1);
   
curl_setopt($chCURLOPT_POSTFIELDS,$params);
   
curl_setopt($chCURLOPT_URL,$_url);
   
curl_setopt($chCURLOPT_SSL_VERIFYHOST2);
   
curl_setopt($chCURLOPT_USERAGENT$defined_vars['HTTP_USER_AGENT']);
   
curl_setopt($chCURLOPT_RETURNTRANSFER,1); 
   
$result=curl_exec ($ch);
   
curl_close ($ch);

    echo(
"Output: ".$result);

?>
helvecio_oliveira at yahoo dot com dot br
21-Aug-2003 11:12
CURL install steps in Mandrake 9.1:
==========================================================
cp -r /usr/src/php-devel/extensions/curl /tmp/curl
cd /tmp/curl
phpize
./configure
make install
echo "extension = curl.so" > /etc/php/90_curl.ini

Restart apache web server.
==========================================================
curl.so is in:
/usr/lib/php/extensions/

look in phpinfo, the string:
/etc/php/90_curl.ini

Needs these  tools:
autoconf
automake
libtool
m4
php430-devel-430-11mdk.rpm

Some docs:
/usr/share/doc/php430-devel-430/SELF-CONTAINED-EXTENSIONS
16-Jul-2003 05:01
Thanks to one of the posts above for pointing me in the right direction. If you get errors when trying to use php_curl.dll that it cannot be found and you have checked you have all the other dll's list above. If you used the installer package and copied the php_curl.dll from the binaries over because it is not included you also need to copy all the other extenstions dlls over and overwrite the others - then bingo it works!

PS If you are installing on W2003 don't forget to allow the php.exe and other dlls to work in the new server extentsions on the iis tree.
eric at imap dot ch
07-Jul-2003 11:38
I managed to use curl to retrieve information from severs on ports other than 80 or 443 (for https) on some installations but not on all.
If you get an "CURLE_COULDNT_CONNECT /* 7 */" error, try adding the port : (for example)
curl_setopt($ch, CURLOPT_PORT, $_SERVER['SERVER_PORT']);
php at mechintosh dot com
03-Jul-2003 10:51
IMHO the example code is somewhat confusing; the fopen() and fclose() are not needed at all, AFAICT.

By default the resulting data/page of the external server is just printed out. To assign the result of the curl session to a variable, one can use
- output buffering (see ob_start(), ob_get_contents())
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
With the latter, the result of curl_exec is the actual data instead of a boolean.
jacob_at_keystreams_dot_com
28-Jun-2003 04:01
It should be noted that to use curl with https you must make sure that (lib)curl was configured with the --with-ssl=/path-to/(open)ssl AND that apache is running with SSL support (mod_ssl). If both of these aren't done you will get an error saying 'libcurl was built with SSL disabled, https: not supported!' This may seen obvious to some but thought it warranted a note.
www dot php dot net at roderick dot triple-it dot nl
16-Jun-2003 04:31
Using CURL && Openssl
=================

If you get an error like this:
~~
Error 35: SSL: error:14090086:lib(20):func(144):reason(134)
~~

It means that the verifcation path is unsuccessful (I guess).

Anyway, a somewhat unsecure workaround is:
~~
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
~~

Hope this helpes somebody..
(I was already installing egd, prngd and SUNWski stuff)

Kind Regards,

Roderick Groesbeek
yc at_ laposte dot_ net
21-May-2003 06:46
Do not try to send mutliple HTTP requests with one curl session, because this seems to cause curl to hang randomly, though the requests are executed without problem. So it seems much more efficient to do a curl_close and curl_init between each request.
hope this helps
sorin
10-Apr-2003 03:44
function curl_string ($url,$user_agent,$proxy){

        $ch = curl_init();
        curl_setopt ($ch, CURLOPT_PROXY, $proxy);
        curl_setopt ($ch, CURLOPT_URL, $url);
        curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent);
        curl_setopt ($ch, CURLOPT_COOKIEJAR, "c:\cookie.txt");
        curl_setopt ($ch, CURLOPT_HEADER, 1);
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt ($ch, CURLOPT_TIMEOUT, 120);
        $result = curl_exec ($ch);
        curl_close($ch);
        return $result;
   
}

$url_page = "http://www.google.com/";
$user_agent = "Mozilla/4.0";
$proxy = "http://208.25.243.167:8080";
$string = curl_string($url_page,$user_agent,$proxy);
echo $string;

this could hep someone
Sorin
thomas at NOSPAM dot gutschke dot com
07-Apr-2003 07:00
Here's a little code snippet if you need the last-modified-time for a remote file as filemtime() does not work on those. :)

$modified = "";
function read_header($ch, $header)
{
    global $modified;
    $length = strlen($header);
    if(strstr($header, "Last-Modified:"))
    {
        $modified = substr($header, 15);
    }
    return $length;
}

function last_mod($remote_file)
{
    global $modified;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $remote_file);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_NOBODY, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'read_header');

    $headers = curl_exec ($ch);
    curl_close ($ch);
    return $modified;
}

use something like
    echo strtotime(last_mod("http://www.php.net/"));
to get the time as an Unix timestamp or
    echo last_mod("http://www.php.net/");
to get the gmdate()-like time.
dweingart at pobox dot com
03-Apr-2003 06:08
If you want to Curl to follow redirects and you would also like Curl to echo back any cookies that are set in the process, use this:

curl_setopt($ch, CURLOPT_COOKIEJAR, '-');

'-' means stdout

-dw
diana dot castillo at nvtechnologies dot com
26-Mar-2003 02:30
if you need to install curl on a windows system, this has the best explanation:
http://zend.com/zend/tut/tutorial-thome3.php
bharris at spro dot net
26-Feb-2003 08:58
For Win2000: To get the 4.3.1 curl dll to work with https you now need to download the latest win32 curl library from http://curl.haxx.se and snag the ca-bundle.crt file from the lib directory.  Place this somewhere handy on your webserver.

Then in your PHP script, add the following setopt line to the rest of your curl_setopt commands:

curl_setopt($ch, CURLOPT_CAFILE, 'C:\pathto\ca-bundle.crt')

This worked for me and allowed me to discontinue using the CURLOPT_SSL_VERIFYPEER set to zero hack.
stain at dxml dot org
13-Feb-2003 08:33
php 4.3.0 + curl 7.10.3

in my php code i do something like:

<code>
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, 'https://www.example.com/path/to/file.ext');

ob_start();
curl_exec ($ch);
ob_end_flush();

if (curl_error($ch))
        printf("Error %s: %s", curl_errno($ch), curl_error($ch));

curl_close ($ch);
</code>

and i retrieve an error like:

Error 35: SSL: error:xxxxxxxx:lib(xx):func(xxx):reason(xxx)

curl error 35 is CURLE_SSL_CONNECT_ERROR 

from SSLCERTS file in curl source directory:
"Starting in 7.10, libcurl performs peer SSL certificate verification by
default.
[...]
If the remote server uses a self-signed certificate, or if you don't install
curl's CA cert bundle or if it uses a certificate signed by a CA that isn't
included in the bundle, then you need to do one of the following:
 1. Tell libcurl to *not* verify the peer. With libcurl you disable with with
    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);
    With the curl command tool, you disable this with -k/--insecure.
[...]"

(i suggest to read all the info provided with curl distribution)

so, in php, you need do the following:

curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);

 i would be sure my connection don't crash, but since i didn't find any other documentation available, i add also the following:

curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);

from php manual:
"CURLOPT_SSL_VERIFYHOST: Pass a long if CURL should verify the Common name of the peer certificate in the SSL handshake. A value of 1 denotes that we should check for the existence of the common name, a value of 2 denotes that we should make sure it matches the provided hostname. "

HTH

bye, stain.
jobob AT yahoo.com
23-Jan-2003 02:18
There is a site which uses curl to do a lot of automated link checking in a script is <a href="http://listbid.com/affil/>affiliate source</a> which seems to be pretty interesting in the script they use. Here is a modified version.

function GetCurlPage ($pageSpec) {
  if(function_exists('curl_init'){
    $agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)";
    $ref = "http://listbid.com/affil/";

       $ch = curl_init($pageSpec);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, $agent);
    curl_setopt($ch, CURLOPT_REFERER, $ref);

       $tmp = curl_exec ($ch);
       curl_close ($ch);
       $ret = $tmp;
  }else{
       $ret = @implode('', @file ($pageSpec));
}
    return $ret;
}

This check if CURL is installed first before attempting to call it, this is for those of you who are not sure if it is. (shared hosting etc.)

cheers
retro at nospam dot enx dot org
12-Jan-2003 09:42
When using cURL to do posts, make sure you actually specify the CURLOPT_POSTFIELDS option. Not doing so seems to make PHP core (and apache as well if you're running it through there).
laurinus at blubb dot at
03-Jan-2003 02:55
Halleluja - it took me 2 Days to find this...

David Withnall wrote:
There are 2 windows install versions of php available on the php site. the first is the executable install. the second is the zipped binary.
If you install php using the executable install it does not install php_curl.dll If you then copy this dll out of the zipped binary and put it into the extensions directory it will fail. This is because the dlls in the zipped binary are not in sync with the executable install.
20-Dec-2002 12:03
mwartman, perhaps you need to use https:
$ch = curl_init ("https://server.com/file.req");
asi at neo dot ee
13-Dec-2002 11:28
If anybody has problems with getting new curl working with older version of php then ...

I got stuck with installing curl-7.10.2+php 4.0.6 or better said configuring PHP with mentioned version of curl.

After some hopeless attempts to configure curl support into PHP I saw an error message:

"checking for cURL greater than or equal to 7.8... ./configure: line 11725: test: 070a02: integer expression expected"

after which configure said: "configure: error: cURL version 7.8 or later is required to compile php with cURL support"

On the mentioned line "test" is used to compare verion from curl-sonfig with preset value 70800 but ... test expects both values to be integer. From verson 7.8 curl outputs its version in hex...

I did'nt had the time to think about fixing this - I just deleted lines responsible and got curl working :)
mwartman at betterbuilt dot com
02-Nov-2002 06:57
a note on installing apache+php+ssl+curl+mysql. this is cake. if you go to nusphere.com and download their free tech platform, it is a nice easy little web based installer that installs and configures apache, mysql, posgresql, ssl, php, phpmyadmin, and a few other tools i can't think of right now. to get it working with curl support, all you have to do is edit the c:\Program Files\nusphere\apache\php\php.ini, and remove the ; from in front of the php_curl extension. it's all up and running in minutes. =]
jerome at blaster dot dyndns dot org
10-Oct-2002 09:23
I wanted to import an https Web pages thanks to fopen("https://xxx", "r") or fsockopen but as far as I read, it was only possible with cURL extension (to get these functions worked with https, we have to wait the PHP 4.3 release, TBC) , so I installed it and it worked. It is quite easy, but I spend to much time on it:
First of all, here is the most important: WE DON'T NEED to compile anything to get curl worked. All the extensions that we need are already in the PHP 4.2.3 zip. So here are the instructions and links to get Apache + PHP + CURL work properly:

Downloads:
=> Apache Web server with Openssl included:
   http://www.modssl.org/contrib/ftp/contrib/ Apache_1.3.26-Mod_SSL_2.8.9-OpenSSL_0.9.6d-WIN32.zip

=> PHP 4.2.3 for Windows:
   http://www.php.net/get_download.php?df=php-4.2.3-Win32.zip

=> Optional: Openssl zip to get libeay32.dll and ssleay32.dll (I didn't need them because I used those stored in PHP zip)
http://www.modssl.org/contrib/ftp/contrib/ OpenSSL-0.9.6d-win32_RAR3_Archive_.rar

Installs:
=> Unzip Apache in Program Files folder(there should be no problem with the blank in the path):

=> Follow those instructions: http://tud.at/programm/apache-ssl-win32-howto.php3 . I didn't exactly do what they wrote but it helped a lot. I created the test certificat thanks to this link in order to test my Apache server with SSL.

=> Configure httpd (easy to find on the Web) and test Apache before going on, it avoids problems.
   I just changed the Port from 80 (http) to 443 (https) in httpd, I only wanted to perform https.
   I didn't try to get the both working together.

=> Unzip PHP in C:\Php path (don't install it in Program Files folder, you would have troubles because of the blank this time...)

=> Configure PHP : http://www.php.net/manual/en/install.windows.php #install.windows.manual
   WARNING: php.ini MUST be stored into the c:\winnt folder and the dlls must be stored into the c:\winnt\system32 folder.

=> Test it with Apache and phpinfo() function.

cURL:
To add cURL extension, YOU DON'T NEED to compile anything.
All the extensions that you need are in the C:\php\extensions folder. To add cURL or any other extensions:

=> Have the libeay32.dll and ssleay32.dll in the system32 folder (already done if you installed PHP)

=> Copy all dlls from php/dll/ folder to winnt/system32/ (libeay32.dll and ssleay32.dll are already there if you followed
   the previous steps)

=> Remove the ";" in front of extension=php_curl.dll in php.ini.

Those instructions come from: http://www.php.net/manual/en/install.windows.php #install.windows.extensions

And it should work, just test it with curl functions into your php script.
steve at bakeacake dot com
17-Sep-2002 11:41
When opening a webpage with cURL, returns are a "\n" when you open a webpage with file the returns are a "\r".
ibyte(at)SPAMISKILLEDnoxs.nl
26-Aug-2002 07:31
[Editors note]
Make sure that the supplied libeay32.dll and ssleay32.dll
(in the dlls-Folder) are on a path where PHP can find them.

A tip for Windows users (and possibly others): if you really can't get the cURL library (php_curl.dll) to work (like me), but you can get the precompiled command line utility (curl.exe) that's available from the cURL site to work, you can use PHP's system command execution facilities, like the backtick operator, to invoke cURL and obtain its output.
hamannDOTw at tDOTonline dot de
02-Jul-2002 11:18
Using the customrequest for a complete post is wrong. Libcurl will add a partial url, the http version and the standard headers after the post data - while this works with a non-persistent connection and an apache web server, it may fail under different conditions
smclean at scoreinfo dot tv
22-Jun-2002 08:46
For an exaplanation of those Predefined Constants listed above see the following URL:

 http://curl.haxx.se/libcurl/c/curl_easy_setopt.html
brian dot m at bizatomic dot com
26-May-2002 02:30
NOTE:
There is a bug in cURL version 7.9.4 that can cause problems form posts.

I just spent a couple hours pulling my hair out over this.

I just upgraded to 7.9.7 and everything seems to work fine.

Here's a link to info on the cURL site.
http://curl.haxx.se/mail/lib-2002-02/0029.html
orangevwbus at yahoo dot com
06-Jan-2002 11:12
In win32 (Windows 2000), I couldn't get apache to start with PHP/curl support 'cause it said it couldn't find the php_curl.dll.  Well it was there.
MSVCRT.dll was there as well, but after I ran the dll through "Depends", there's a new DLL for the Microsoft .NET stuff. It's called msvcr70.dll, and without it, php_curl.dll won't load.
I didn't want to load .NET framework on my machine (which msdn.microsoft.com suggested)
I did a google search and found a downloadable copy of the file and threw it in my %system%\system32 folder and all the lights and whistles came on.
jeff at vertexdev dot com
23-Sep-2001 06:22
<p>The PHP 4.0.6 code contains some functions that are not documented on this page:</p>

<p>curl_getinfo(int ch) - Returns an associative array with detailed information about the last transfer, including the actual URL fetched, the HTTP response code, and the time taken to perform each phase of the transfer.</p>

<p>curl_error(int ch) - Returns a descriptive error string containing the last error code for the session.</p>

<p>curl_errno(int ch) - Returns an integer containing the last error number</p>

<p>Here is some output from curl_getinfo():</p>

   Array<br>
  (<br>
    [url] =><br> http://www.moreover.com/cgi-local/page?feed=525&o=rss<br>
    [http_code] => 200<br>
    [header_size] => 261<br>
    [request_size] => 155<br>
    [filetime] => 0<br>
    [total_time] => 0.7408<br>
    [namelookup_time] => 0.031381<br>
    [connect_time] => 0.154251<br>
    [pretransfer_time] => 0.154589<br>
    [size_upload] => 0<br>
    [size_download] => 5612<br>
    [speed_download] => 3133.7556977376<br>
    [speed_upload] => 0<br>
  )<br>
marco dot mcc at inwind dot it
28-May-2001 01:50
If you want to write your entire HTTP request without use any other CURL functions like CURLOPT_POST specify it within a curl_setopt ($ch,CURLOPT_CUSTOMREQUEST , $req) line;
Where $req looks like (let me imagine a POST request...):

POST /destination/script HTTP/1.1
Content-length: xxx
Content-type: text/xml
host: yourhost
accept: */*
accept-encoding: gzip, deflate
accept-language: en-us
connection: close; Keep-Alive
...
your POST data
...


CURLOPT_CUSTOMREQUEST is not documented?!? but it's useful and amazing!

marcomcc (Roma)
tom dot anheyer at berlinonline dot de
09-Feb-2001 08:01
string curl_error(int ch)
   Return a string contain the last error for the current session
int curl_errno(int ch)
   Return an integer containing the last error number

the error codes are defined as constants in ../ext/curl/curl.c
dan dot polansky at seznam dot cz
18-Jan-2001 06:31
I used to download www pages to my script and one of the pages was different in MS explorer and different, when I downloaded it. Namely, information, I was really interested in was missing. That was because the server on the other bank of the river was looking at who is downloading the page. Everything got fixed when I pretended I was MSIE. It is done with curl. Here is a function, that you may use in similar situation

function download_pretending($url,$user_agent) {
   $ch = curl_init();
   curl_setopt ($ch, CURLOPT_URL, $url);
   curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent);
   curl_setopt ($ch, CURLOPT_HEADER, 0);
   curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
   $result = curl_exec ($ch);
   curl_close ($ch);
   return $result;
}
emilebosch at hotmail dot com
16-Dec-2000 11:31
[Editor's Note]
Please note that you can load the php_curl.dll extension by modifying your php.ini file to include the correct extension_dir setting and then adding or uncommenting the extension line for php_curl.dll, you do not need to copy the extension to your windows directory.

For all you people that can't get CURL to work on Windows load the Dynamic Library by using:

dl("php_curl.dll");

if it says something like: can't use or load library files (or missing dll), it's missing some DLL's like
php4ts.dll,SSLEAY32.dll,php_curl.dll,MSVCRT.dll locate these DLL's in your PHP binary and put them in your windows SYSTEM directory, i actually found this out by editing the php_curl.dll file and looked for the DLL files its need (by searching for .dll) and just made sure that those files where accessible by this DLL.

Good luck,
Emile
macmaster at pobox dot com
05-Nov-2000 10:42
To return the output into a variable set CURLOPT_RETURNTRANSFER to 1, so saith the php-dev list.

<crack_opendictcurl_close>
 Last updated: Thu, 21 Aug 2003
show source | credits | sitemap | mirror sites 
Copyright © 2001-2003 The PHP Group
All rights reserved.
This mirror generously provided by: http://php.mirrors.ilisys.com.au/
Last updated: Sat 01 Nov 2003 04:13:36 EST EST