2. Suporta FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, FILE, LDAP. SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, kerberos...), file transfer resume, proxy tunneling and a busload of other O que cURL? 3. Quem utiliza? 4. Outros parecidos Libwww || WinInet || Jakarta Commons HttpClienthttp://curl.haxx.se/libcurl/competitors.htmlhttp://curl.haxx.se/docs/comparison-table.html 5. Como funciona? Aplicativo Servidor aplicativo Servidor de imagens GET / [URL] HTTP/1.1 HTTP/1.x 200 OK Ambiente Cliente / Servidor (Browser) GET / [URL] HTTP/1.1 HTTP/1.x 200 OK 6. Mas e a cURL??? Aplicativo Servidor hospedeiro Script rodando no servidor Browser rodando no cliente Ambiente Cliente / Servidor (cURL) Ambiente Cliente / Servidor (Browser) GET / [URL] HTTP/1.1 HTTP/1.x 200 OK GET / [URL] HTTP/1.1 HTTP/1.x 200 OK 7. Como fica? Setar como ISO-8859-1 Input charset encoding Internal charset encoding Output charset encoding 8. Show me the code! Primeiro Exemplo Cdigo captado no site php.net na URL http://br.php.net/curl Desenvolvido por Ojas Ojasvi em 25/Set/2007 contendo um simples exemplo de como simular um acesso ao site utilizando-se de um browser e ambiente fake 9. Base principal 10. Ambiente do cliente // Inicializa a cURL $curl = curl_init(); // seta os cabealhos $header[0] = "Accept: text/xml,application/xml,; $header[0] .= application/xhtml+xml,text/html;; $header[0] .= q=0.9,text/plain;q=0.8,image/png,; $header[0] .= */*;q=0.5"; $header[] = "Cache-Control: max-age=0"; $header[] = "Connection: keep-alive"; $header[] = "Keep-Alive: 300"; $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7"; $header[] = "Accept-Language: en-us,en;q=0.5"; $header[] = "Pragma: "; 11. Alterando o ambiente // Altera o ambiente curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_USERAGENT,'Googlebot/2.1 (+ http://www.google.com/bot.html )' ); curl_setopt($curl,CURLOPT_HTTPHEADER,$header ); curl_setopt($curl, CURLOPT_REFERER,' http://www.google.com '); ... 12. Simples assim! // Efetua a execuo da captura $html = curl_exec($curl); curl_close($curl); // o retorno da funo return $html; 13. S isto! Recomendo a classe cURL disponvel no site phpclasses.org para estudos http://www.phpclasses.org/browse/package/1988.html Exemplo de como baixar imagens buscadas pelo Google que utiliza a classe acima http://www.phpclasses.org/browse/package/2311.html 14. Fim !!! URLs teis phpclasses.org www.phpclasses.orgSite oficial do cURL curl.haxx.se Meu Blog programabrasil.blogspot.com Agradecimentos cURL Team Ojas Ojasvi phpClasses.org