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
76
votes
5 answers

Using curl to send email

How can I use the curl command line program to send an email from a gmail account? I have tried the following: curl -n --ssl-reqd --mail-from "" --mail-rcpt "" --url smtps://smtp.gmail.com:465 -T file.txt With…
NSNolan
  • 1,025
  • 1
  • 13
  • 18
75
votes
1 answer

SOAP request in PHP with CURL

Since the SOAP manual on php.net is not very noob friendly and I could not find any good examples I will post my question here. How can I create PHP SOAP request to look like this? POST /MySERVER/myWSDLservice.asmx HTTP/1.1 Host:…
Iladarsda
  • 10,640
  • 39
  • 106
  • 170
75
votes
2 answers

Curl post data and headers only

I want to get the headers only from a curl request curl -I www.google.com All grand. Now I want to do that but to pass in post data too: curl -I -d'test=test' www.google.com But all I get is: Warning: You can only select one HTTP request! Anyone…
J.D. Fitz.Gerald
  • 2,977
  • 2
  • 19
  • 17
75
votes
6 answers

Get page output with curl --fail

Calling curl without parameters, i get the page output, even with an http status code = 404: $ curl http://www.google.com/linux;
Thom Thom Thom
  • 1,279
  • 1
  • 11
  • 21
72
votes
4 answers

Send cookies with curl

I am using curl to retrieve cookies like so: curl -c cookies.txt url then I parse the cookie I want from the cookies.txt file and send the request again with the cookie curl -b "name=value" url Is this the correct way to send the cookie? Is there…
dmz73
  • 1,588
  • 4
  • 20
  • 32
72
votes
11 answers

Fatal error: Call to undefined function curl_init()

base64_encode($data), 'key' => IMGUR_API_KEY); $timeout = 30; $curl =…
Thew
  • 15,789
  • 18
  • 59
  • 100
72
votes
2 answers

How can I remove default headers that cURL sends?

Curl by default adds headers such as Content-type and User-agent. Normally that is a good thing but I'm trying to test what our server does when those headers are missing. My problem is with the Content-type header. If it is missing, the server…
Jilles van Gurp
  • 7,927
  • 4
  • 38
  • 46
72
votes
3 answers

osx 10.10 Curl POST to HTTPS url gives SSLRead() error

I just recently upgraded to OSX 10.10 Yosemite and I since the upgrade I can't do Curl POST to a SSL url anymore. I first used wordpress's wp_remote_request call and also tried to use curl in php. Both (as expected) give the same error…
Mattijs
  • 3,265
  • 3
  • 38
  • 35
72
votes
1 answer

Download file with url redirection

I can download a file by url but when I try it from bash I get a html page instead of a file. How to download file with url redirection (301 Moved Permanently) using curl, wget or something else? UPD Headers from the url request. curl -I…
edem
  • 3,222
  • 3
  • 19
  • 45
72
votes
7 answers

How can a Jenkins user authentication details be "passed" to a script which uses Jenkins API to create jobs?

I have a script that delete and re-create jobs through curl HTTP-calls and I want to get rid of any hard-coded "username:password". E.g. curl -X POST $url --user username:password Considerations: Jenkins CLI (probably not an option). One should be…
HenrikSN
  • 850
  • 1
  • 6
  • 10
71
votes
13 answers

Equivalent of cURL for Ruby?

Is there a cURL library for Ruby?
user85748
  • 1,213
  • 3
  • 14
  • 21
70
votes
12 answers

cURL error 60: SSL certificate problem: certificate has expired

We running 2 application on amazon EC2 (backend.example.com & frontend.example.com). For that application, we used a paid SSL Certificate. That certificate expiration date at 2021 June. But today, we got an error - cURL error 60: SSL certificate…
Hasan Hafiz Pasha
  • 1,402
  • 2
  • 17
  • 25
70
votes
3 answers

curl usage to get header

Why does this not work: curl -X HEAD http://www.google.com But these both work just fine: curl -I http://www.google.com curl -X GET http://www.google.com
Ankur Agarwal
  • 23,692
  • 41
  • 137
  • 208
70
votes
5 answers

PHP cURL GET request and request's body

i'm trying using cURL for a GET request like this: function connect($id_user){ $ch = curl_init(); $headers = array( 'Accept: application/json', 'Content-Type: application/json', ); curl_setopt($ch, CURLOPT_URL,…
itsme
  • 48,972
  • 96
  • 224
  • 345
70
votes
3 answers

PHP: Default cURL timeout value

What is the default PHP cURL timeout value? Can I obtain the value from coding?
Raptor
  • 53,206
  • 45
  • 230
  • 366