cURL

:// cURL logotyp

Version av curl

curl --version

Vilken curl?

which curl

Sökväg

/usr/bin/curl

Manual för UNIX

man curl curl --manual | less

Hämta fil med UNIX

curl -O

Visa källkod med UNIX

curl -i

Hämta headers med UNIX

curl -I

Logga in med UNIX

curl -u username:password http://example.com

Sätt webbläsare med UNIX

curl -A "UserAgentString" http://url.com

Sätt headers med UNIX

curl -H

Skicka en post UNIX

curl -X

Lägg till data för post

curl -d

Filer med UNIX

curl -F

Följ med UNIX

curl -L

Sätt cookies med UNIX

curl -c ~/.cookie-file

Hämta cookies med UNIX

curl -b ~/.cookie-file

Visa progress med UNIX

curl -# curl --progress-bar

UNIX $_SERVER['HTTP_REFERER']

curl -L -e ";auto"

FTP using cURL (länk)

Download a file using FTP

curl ftp://myftpsite.com/mp3/mozart_piano_sonata.zip --user myname:mypassword -o mozart_piano_sonata.zip

Upload a file using FTP

curl -T koc_dance.mp3 ftp://myftpsite.com/mp3/ --user myname:mypassword

List files in sub directories

curl ftp://myftpsite.com/mp3/ --user myname:mypassword

List only directories, silent the curl progress bar, and use grep to filter

curl ftp://myftpsite.com --user myname:mypassword -s | grep ^d

Remove files using FTP

This is a bit tricky, because curl do not support that by default, well anyway, you can make use of -X and pass in the REAL FTP command. (Check out a list of FTP service Command in rfc 959, under 4.1.3. FTP SERVICE COMMANDS)

curl ftp://myftpsite.com/ -X 'DELE mp3/koc_dance.mp3' --user myname:mypassword

Caution: Make sure you are know what are you deleting! It will not prompts ‘Are you sure?’ confirmation. Daniel Stenberg

Personer

Datum

Nyhet

Open connection PHP

$ch = curl_init();

Set the url, number of POST vars, POST data PHP

curl_setopt($ch, CURLOPT_URL, 'https://hooks.slack.com/services/lorem/ipsum/dolor'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, 'payload={"channel": "#channel", "username": "Name of the bot", "text": "' . urlencode($variabel) . '", "icon_emoji": ":space_invader:"}'); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_HEADERFUNCTION, "functionForHeader"); $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);

Execute post PHP

$result = curl_exec($ch);

Close connection PHP

curl_close($ch); Graf som visar hur mycket cURL förändras över tid

Om cURL inte finns

Mer än PHP5

sudo apt-get install php-curl

Mindre än PHP5

sudo apt-get install php5-curl

Starta om Apache

sudo service apache2 restart http

Protokoll

UNIX timestamp PHP logotyp

Programmeringsspråk

UNIX timestamp

Terminal

http Cookies

Delar

Liknande

  • wget
  • fetch
Logotyp för Haxx

Externa länkar

Rip curl logotyp

Kuriosa

Curlingstenar