Skip to content

Instantly share code, notes, and snippets.

@edueo
Last active April 13, 2017 13:25
Show Gist options
  • Select an option

  • Save edueo/ea81181503ef5c8fa6a8a653ebdb8791 to your computer and use it in GitHub Desktop.

Select an option

Save edueo/ea81181503ef5c8fa6a8a653ebdb8791 to your computer and use it in GitHub Desktop.
curl

curl

Postar um formulário

curl --form name=Peter --form age=23 --form upload=@~/myfile.pdf http://httpbin.org/post

Fazer download de um arquivo

curl -O http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz

Headers de uma requisição

curl -I https://deliciousbrains.com

PHP com cURL

<?php
$curl = curl_init( 'https://httpbin.org/post' );
curl_setopt( $curl, CURL_POST, true );
curl_setopt( $curl, CURLOPT_POSTFIELDS, array('field1' => 'some data', 'field2' => 'some data'));
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec( $curl );
curl_close( $curl );
?>

Não verificar SSL

curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $handle, CURLOPT_SSL_VERIFYHOST, false );

Use Proxy

curl_setopt( $handle, CURLOPT_PROXY, "127.0.0.1" );
curl_setopt( $handle, CURLOPT_PROXYPORT, 8888 ) ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment