Questions tagged [curl]

cURL is a library and command-line tool for transferring data using various protocols such as HTTP, FTP and SFTP. The cURL project produces two products, libcurl and curl. This tag covers all usages of cURL, regardless of which cURL product is used.

The cURL project consists of a command-line tool, curl, and a C library, libcurl, for transferring data using internet protocols such as DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, SSH, Telnet and TFTP

For example, curl can be used to download a web page and save it to a file:

curl -o curltest.html www.example.com

, written in , has bindings for a number of languages. Please use the tag for questions about compiling or integrating cURL into another project (i.e. compiling with cURL support).

is an example of a project that has implemented cURL and its use has become quite popular, due to its versatility.

Common PHP Questions

Resources

43780 questions
99
votes
12 answers

How to fix curl: (60) SSL certificate: Invalid certificate chain

I get the following error running curl https://npmjs.org/install.sh | sh on Mac OSX 10.9 (Mavericks): install npm@latest curl: (60) SSL certificate problem: Invalid certificate chain More details here: http://curl.haxx.se/docs/sslcerts.html How do…
leafiy
  • 1,100
  • 1
  • 7
  • 8
98
votes
4 answers

PHP cURL HTTP PUT

I am trying to create a HTTP PUT request with cURL and I can't make it work. I've read many tutorials but none of them actually worked. Here's my current code: $filedata = array('metadata' => $rdfxml); $ch = curl_init($url); $header = "Content-Type:…
user601513
  • 981
  • 1
  • 7
  • 3
98
votes
6 answers

Passing $_POST values with cURL

How do you pass $_POST values to a page using cURL?
Scott Gottreu
  • 3,586
  • 4
  • 28
  • 34
98
votes
14 answers

curl error 18 - transfer closed with outstanding read data remaining

when retrieving data from a URL using curl, I sometimes (in 80% of the cases) get error 18: transfer closed with outstanding read data remaining Part of the returned data is then missing. The weird thing is that this does never occur when the…
David
  • 3,075
  • 3
  • 26
  • 36
98
votes
2 answers

how to upload file using curl with PHP

How can I upload a file, either by using cURL or anything else, in PHP? In other words, the user sees a file upload button on a form, the form gets posted to my PHO script, then my PHP script needs to re-post it to another script (eg on another…
Hadidi44
  • 1,007
  • 2
  • 9
  • 7
98
votes
5 answers

How to switch from POST to GET in PHP CURL

I have tried switching from a previous Post request to a Get request. Which assumes its a Get but eventually does a post. I tried the following in PHP : curl_setopt($curl_handle, CURLOPT_POSTFIELDS, null); curl_setopt($curl_handle, CURLOPT_POST,…
gnosio
  • 1,639
  • 3
  • 14
  • 14
98
votes
2 answers

How to check if an URL exists with the shell and probably curl?

I am looking for a simple shell (+curl) check that would evaluate as true or false if an URL exists (returns 200) or not.
sorin
  • 161,544
  • 178
  • 535
  • 806
96
votes
10 answers

ios Upload Image and Text using HTTP POST

Thanks for reading. I am new to iOS and I am trying to upload an Image and a text using multi-part form encoding in iOS. The curl equivalent is something like this: curl -F "param1=value1" -F "param2=@testimage.jpg"…
Sagar Hatekar
  • 8,700
  • 14
  • 56
  • 72
96
votes
1 answer

What is the incentive for curl to release the library for free?

I recently started using libCurl for my VC++ project. I've been wondering: what is the incentive for the curl creators to release the entire library for free? Is it purely to help their fellow developers? This is one of the best open source…
nsivakr
  • 1,565
  • 2
  • 25
  • 46
96
votes
6 answers

What does '--user' mean with curl

I'm working with an API and I have to send a POST request. I know how to set a header (-H) and (-d) is the body, but what is "--user". If I submit this with Postman, or in a text editor with axios or just regular XMLRequest, where do I add this? The…
anon
  • 2,143
  • 3
  • 25
  • 37
95
votes
4 answers

Passing parameters to bash when executing a script fetched by curl

I know how to execute remote Bash scripts like this: curl http://example.com/script.sh | bash or bash < <( curl http://example.com/script.sh ) which give the same result. But what if I need to pass arguments to the bash script? It's possible when…
Daniel R
  • 1,515
  • 2
  • 12
  • 14
95
votes
15 answers

Remote file size without downloading file

Is there a way to get the size of a remote file http://my_url/my_file.txt without downloading the file?
dassouki
  • 6,286
  • 7
  • 51
  • 81
95
votes
9 answers

PowerShell's Invoke-RestMethod equivalent of curl -u (Basic Authentication)

What is the equivalent of curl -u username:password ... in PowerShell's Invoke-RestMethod? I tried this: $securePwd = ConvertTo-SecureString "password" -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential…
Borek Bernard
  • 50,745
  • 59
  • 165
  • 240
94
votes
5 answers

Downloading a large file using curl

I need to download remote file using curl. Here's the sample code I have: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $st = curl_exec($ch); $fd = fopen($tmp_name, 'w'); fwrite($fd,…
kusanagi
  • 14,296
  • 20
  • 86
  • 111
94
votes
6 answers

Ubuntu: Using curl to download an image

I want to download an image accessible from this link: https://www.python.org/static/apple-touch-icon-144x144-precomposed.png into my local system. Now, I'm aware that the curl command can be used to download remote files through the terminal. So, I…
Manas Chaturvedi
  • 5,210
  • 18
  • 52
  • 104