A Biblioteca cURL

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Notes on slide 1

    Se apresentar Fazer agradecimentos Explicar sobre o objetivo do speech

    3 Favorites

    A Biblioteca cURL - Presentation Transcript

    1. Ricardo Striquer Soares programabrasil.blogspot.com
    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 HttpClient http://curl.haxx.se/libcurl/competitors.html http://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 Código 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 <?PHP function disguise_curl ($url) { // Inicializa a cURL ... // seta os cabeçalhos ... // Altera o ambiente ... // Efetua a execução da captura ... return $html; } echo disguise_curl(' http://www.php.net '); ?>
    10. Ambiente do cliente // Inicializa a cURL $curl = curl_init(); // seta os cabeçalhos $header[0] = &quot;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&quot;; $header[] = &quot;Cache-Control: max-age=0&quot;; $header[] = &quot;Connection: keep-alive&quot;; $header[] = &quot;Keep-Alive: 300&quot;; $header[] = &quot;Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7&quot;; $header[] = &quot;Accept-Language: en-us,en;q=0.5&quot;; $header[] = &quot;Pragma: &quot;;
    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 execução da captura $html = curl_exec($curl); curl_close($curl); // o retorno da função return $html;
    13. Só isto! Recomendo a classe cURL disponível 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.org Site oficial do cURL curl.haxx.se Meu Blog programabrasil.blogspot.com Agradecimentos cURL Team Ojas Ojasvi phpClasses.org

    + ricardophpricardophp, 3 years ago

    custom

    1754 views, 3 favs, 0 embeds more stats

    Integração de sistemas e captura de conteúdo onl more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1754
      • 1754 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 3
    • Downloads 25
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories