2002-04-15 00:12:54 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2004-03-06 02:40:23 +00:00
|
|
|
<!-- $Revision: 1.11 $ -->
|
2002-04-15 00:12:54 +00:00
|
|
|
<reference id="ref.curl">
|
|
|
|
<title>CURL, Client URL Library Functions</title>
|
|
|
|
<titleabbrev>CURL</titleabbrev>
|
|
|
|
|
2002-04-19 15:07:14 +00:00
|
|
|
<partintro>
|
|
|
|
<section id="curl.intro">
|
|
|
|
&reftitle.intro;
|
|
|
|
<para>
|
|
|
|
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.
|
|
|
|
</para>
|
|
|
|
<para>
|
2002-11-25 23:49:22 +00:00
|
|
|
These functions have been added in PHP 4.0.2.
|
2002-04-19 15:07:14 +00:00
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section id="curl.requirements">
|
|
|
|
&reftitle.required;
|
|
|
|
<para>
|
|
|
|
In order to use the CURL functions you need to install the <ulink
|
|
|
|
url="&url.curl;">CURL</ulink> package. PHP requires that you use
|
|
|
|
CURL 7.0.2-beta or higher. PHP will not work with any version of
|
2004-03-06 02:40:23 +00:00
|
|
|
CURL below version 7.0.2-beta. In PHP 4.2.3, you will need
|
2003-06-10 03:08:01 +00:00
|
|
|
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
|
2002-04-19 15:07:14 +00:00
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
|
2002-11-25 23:49:22 +00:00
|
|
|
&reference.curl.configure;
|
2002-04-19 15:07:14 +00:00
|
|
|
|
|
|
|
&reference.curl.constants;
|
|
|
|
|
|
|
|
<section id="curl.examples">
|
|
|
|
&reftitle.examples;
|
|
|
|
<para>
|
|
|
|
Once you've compiled PHP with CURL support, you can begin using
|
2003-01-09 13:20:55 +00:00
|
|
|
the CURL functions. The basic idea behind the CURL functions is
|
2002-04-19 15:07:14 +00:00
|
|
|
that you initialize a CURL session using the
|
|
|
|
<function>curl_init</function>, then you can set all your
|
2003-01-09 13:10:11 +00:00
|
|
|
options for the transfer via the <function>curl_setopt</function>,
|
|
|
|
then you can execute the session with the
|
|
|
|
<function>curl_exec</function> and then you finish off
|
|
|
|
your session using the <function>curl_close</function>.
|
|
|
|
Here is an example that uses the CURL functions to fetch the
|
|
|
|
example.com homepage into a file:
|
2002-04-19 15:07:14 +00:00
|
|
|
<example>
|
|
|
|
<title>Using PHP's CURL module to fetch the example.com homepage</title>
|
|
|
|
<programlisting role="php">
|
2002-04-15 00:12:54 +00:00
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
|
2003-12-15 16:55:22 +00:00
|
|
|
$ch = curl_init("http://www.example.com/");
|
|
|
|
$fp = fopen("example_homepage.txt", "w");
|
2002-04-15 00:12:54 +00:00
|
|
|
|
2003-12-15 16:55:22 +00:00
|
|
|
curl_setopt($ch, CURLOPT_FILE, $fp);
|
|
|
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
2002-04-15 00:12:54 +00:00
|
|
|
|
2003-12-15 16:55:22 +00:00
|
|
|
curl_exec($ch);
|
|
|
|
curl_close($ch);
|
|
|
|
fclose($fp);
|
2002-04-15 00:12:54 +00:00
|
|
|
?>
|
|
|
|
]]>
|
2002-04-19 15:07:14 +00:00
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
</section>
|
2002-04-15 00:12:54 +00:00
|
|
|
</partintro>
|
|
|
|
|
|
|
|
&reference.curl.functions;
|
|
|
|
|
|
|
|
</reference>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
indent-tabs-mode:nil
|
|
|
|
sgml-parent-document:nil
|
|
|
|
sgml-default-dtd-file:"../../../manual.ced"
|
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
vi: ts=1 sw=1
|
|
|
|
-->
|