|
użytkowników online: 14
|
OPINIE UŻYTKOWNIKÓW
|
Na początku, kiedy zobaczyłem, że ktoś chce jakiejś opłaty za pomoc w tworzeniu stron ryknąłem śmiechem - potem przyszły problemy... i zaryzykowałem. Druga rzecz to: nie chciałem "kopiować". Ale prawda jest taka: są lepsi, bardziej doświadczeni i... czasem trzeba poprosić o pomoc, a jak poświęca się na to trzecią cześć życia, to nic dziwnego, że nie chce się swoich "sekretów" zdradzać za darmo. Skorzystałem z "algorytmy.pl" i naprawdę jestem z tego w 100% zadowolony, polecam - dla zawodowców (co się uczą) i amatorów (można skorzystać z gotowego rozwiązania).
Tomasz Czypicki
Cybernoxa
|
|
PODRĘCZNIK PHP 5.x, 4.x, 3.x - częściowo spolszczony / źródło: www.php.net
[Spis]
[A]
[B]
[C]
[D]
[E]
[F]
[G]
[H]
[I]
[J]
[K]
[L]
[M]
[N]
[O]
[P]
[Q]
[R]
[S]
[T]
[U]
[V]
[X]
[W]
[Z]
XVI. CURL, Client URL Library Functions
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.
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 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
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 SYSTEM
folder of your Windows machine. (Ex: C:\WINNT\SYSTEM32
or C:\WINDOWS\SYSTEM)
Poniższe stałe są zdefiniowane w tym rozszerzeniu i stają się dostępne, gdy
rozszerzenie jest dokompilowane do PHP, lub załadowane dynamicznie przy starcie.
- CURLOPT_DNS_USE_GLOBAL_CACHE
(integer)
- CURLOPT_DNS_CACHE_TIMEOUT
(integer)
- CURLOPT_FTPSSLAUTH
(integer)
Available since PHP 5.1.0
- CURLOPT_SSLENGINE_DEFAULT
(integer)
- CURLOPT_UNRESTRICTED_AUTH
(integer)
- CURLCLOSEPOLICY_LEAST_RECENTLY_USED
(integer)
- CURLCLOSEPOLICY_LEAST_TRAFFIC
(integer)
- CURLINFO_PRETRANSFER_TIME
(integer)
- CURLINFO_SSL_VERIFYRESULT
(integer)
- CURLINFO_CONTENT_LENGTH_DOWNLOAD
(integer)
- CURLINFO_CONTENT_LENGTH_UPLOAD
(integer)
- CURLINFO_STARTTRANSFER_TIME
(integer)
- CURLE_UNSUPPORTED_PROTOCOL
(integer)
- CURLE_COULDNT_RESOLVE_PROXY
(integer)
- CURLE_COULDNT_RESOLVE_HOST
(integer)
- CURLE_FTP_WEIRD_SERVER_REPLY
(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_COULDNT_SET_BINARY
(integer)
- CURLE_FTP_COULDNT_RETR_FILE
(integer)
- CURLE_FTP_COULDNT_STOR_FILE
(integer)
- CURLE_OPERATION_TIMEOUTED
(integer)
- CURLE_FTP_COULDNT_SET_ASCII
(integer)
- CURLE_FTP_COULDNT_USE_REST
(integer)
- CURLE_FTP_COULDNT_GET_SIZE
(integer)
- CURLE_FTP_BAD_DOWNLOAD_RESUME
(integer)
- CURLE_FILE_COULDNT_READ_FILE
(integer)
- CURLE_ABORTED_BY_CALLBACK
(integer)
- CURLE_BAD_FUNCTION_ARGUMENT
(integer)
- CURLE_BAD_PASSWORD_ENTERED
(integer)
- CURLE_UNKNOWN_TELNET_OPTION
(integer)
- CURLE_TELNET_OPTION_SYNTAX
(integer)
- CURLE_SSL_PEER_CERTIFICATE
(integer)
- CURLE_SSL_ENGINE_NOTFOUND
(integer)
- CURLE_SSL_ENGINE_SETFAILED
(integer)
- CURLE_BAD_CONTENT_ENCODING
(integer)
- CURLFTPAUTH_DEFAULT
(integer)
Available since PHP 5.1.0
- CURLFTPAUTH_SSL
(integer)
Available since PHP 5.1.0
- CURLFTPAUTH_TLS
(integer)
Available since PHP 5.1.0
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:
Przykład 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);
?>
|
|
User Contributed Notesluca dot manzo at bbsitalia dot com
02-Feb-2006 12:55
If you're getting trouble with cookie handling in curl:
- curl manages tranparently cookies in a single curl session
- the option
curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/cookieFileName");
makes curl to store the cookies in a file at the and of the curl session
- the option
curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/cookieFileName");
makes curl to use the given file as source for the cookies to send to the server.
so to handle correctly cookies between different curl session, the you have to do something like this:
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_COOKIEJAR, COOKIE_FILE_PATH);
curl_setopt ($ch, CURLOPT_COOKIEFILE, COOKIE_FILE_PATH);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($ch);
curl_close($ch);
return $result;
in particular this is NECESSARY if you are using PEAR_SOAP libraries to build a webservice client over https and the remote server need to establish a session cookie. in fact each soap message is sent using a different curl session!!
I hope this can help someone
Luca
administrator at gesoft dot org
24-Dec-2005 05:39
|