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
3723
votes
31 answers

How do I POST JSON data with cURL?

I use Ubuntu and installed cURL on it. I want to test my Spring REST application with cURL. I wrote my POST code at the Java side. However, I want to test it with cURL. I am trying to post a JSON data. Example data is like…
kamaci
  • 72,915
  • 69
  • 228
  • 366
2775
votes
31 answers

How do I get a YouTube video thumbnail from the YouTube API?

If I have a YouTube video URL, is there any way to use PHP and cURL to get the associated thumbnail from the YouTube API?
CodeOverload
  • 47,274
  • 54
  • 131
  • 219
1948
votes
11 answers

How to send a header using a HTTP request through a cURL call?

I wish to send a header to my Apache server on a Linux box. How can I achieve this via a cURL call?
gagneet
  • 35,729
  • 29
  • 78
  • 113
1008
votes
15 answers

How do I measure request and response times at once using cURL?

I have a web service that receives data in JSON format, processes the data, and then returns the result to the requester. I want to measure the request, response, and total time using cURL. My example request looks like: curl -X POST -d @file…
sdasdadas
  • 23,917
  • 20
  • 63
  • 148
750
votes
9 answers

How to display request headers with command line curl

Command line curl can display response header by using -D option, but I want to see what request header it is sending. How can I do that?
wwwxml
  • 7,517
  • 3
  • 16
  • 3
746
votes
7 answers

How do I get cURL to not show the progress bar?

I'm trying to use cURL in a script and get it to not show the progress bar. I've tried the -s, -silent, -S, and -quiet options, but none of them work. Here's a typical command I've tried: curl -s http://google.com > temp.html I only get the…
adammenges
  • 7,848
  • 5
  • 26
  • 33
718
votes
9 answers

Getting only response header from HTTP POST using cURL

One can request only the headers using HTTP HEAD, as option -I in curl(1). $ curl -I / Lengthy HTML response bodies are a pain to get in command-line, so I'd like to get only the header as feedback for my POST requests. However, HEAD and POST are…
Jonathan Allard
  • 18,429
  • 11
  • 54
  • 75
703
votes
23 answers

How do I install and use cURL on Windows?

I am having trouble getting cURL to run on Windows. I have downloaded a cURL zip file from here, but it seems to contain source code, not an executable. Do I need to compile cURL to run it? If yes, then how do I do that? Where can I find .exe…
pri_dev
  • 11,315
  • 15
  • 70
  • 122
682
votes
11 answers

How to capture cURL output to a file?

I have a text document that contains a bunch of URLs in this format: URL = "sitehere.com" What I'm looking to do is to run curl -K myfile.txt, and get the output of the response cURL returns, into a file. How can I do this?
Tony
  • 8,681
  • 7
  • 36
  • 55
633
votes
22 answers

Using cURL with a username and password?

I want to access a URL which requires a username/password. I'd like to try accessing it with curl. Right now I'm doing something like: curl http://api.somesite.com/test/blah?something=123 I get an error. I guess I need to specify a username and…
user246114
  • 50,223
  • 42
  • 112
  • 149
627
votes
34 answers

Unable to resolve "unable to get local issuer certificate" using git on Windows with self-signed certificate

I am using Git on Windows. I installed the msysGit package. My test repository has a self signed certificate at the server. I can access and use the repository using HTTP without problems. Moving to HTTPS gives the error: SSL Certificate problem:…
RichardHowells
  • 7,826
  • 3
  • 24
  • 24
625
votes
10 answers

Converting a Postman request to curl

I am calling my Java webservice (POST request) via Postman in the following manner which works perfectly fine (i.e. I can see my records getting inserted into the database): And, here's how the contents inside the Headers(1) tab look like: Instead…
Coder
  • 6,381
  • 2
  • 9
  • 10
624
votes
15 answers

PHP, cURL, and HTTP POST example?

Can anyone show me how to do a PHP cURL with an HTTP POST? I want to send data like this: username=user1, password=passuser1, gender=1 To www.example.com I expect the cURL to return a response like result=OK. Are there any examples?
mysqllearner
  • 13,523
  • 15
  • 43
  • 43
606
votes
3 answers

Is there a way to follow redirects with command line cURL?

I know that in a php script: curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); will follow redirects. Is there a way to follow redirects with command line cURL?
user1592380
  • 34,265
  • 92
  • 284
  • 515
605
votes
24 answers

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I am getting error Expecting value: line 1 column 1 (char 0) when trying to decode JSON. The URL I use for the API call works fine in the browser, but gives this error when done through a curl request. The following is the code I use for the curl…
user1328021
  • 9,110
  • 14
  • 47
  • 78
1
2 3
99 100