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
148
votes
3 answers

curl_exec() always returns false

I have written this simple piece of code : $ch = curl_init(); //Set options curl_setopt($ch, CURLOPT_URL, "http://www.php.net"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $website_content = curl_exec ($ch); In my case $website_content comes as…
Adithya
  • 2,923
  • 5
  • 33
  • 47
147
votes
4 answers

CURL to access a page that requires a login from a different page

I have 2 pages: xyz.example/a and xyz.example/b. I can only access xyz.example/b if and only if I login to xyz.example/a first. If accessing xyz.example/b without going through the other, I simply get access denied (no redirect to login) via the…
ms1013
  • 1,725
  • 2
  • 14
  • 16
145
votes
4 answers

How to use CURL via a proxy?

I am looking to set curl to use a proxy server. The url is provided by an html form, which has not been a problem. Without the proxy it works fine. I have found code on this and other sites, but they do not work. Any help in finding the correct…
user586011
  • 1,908
  • 4
  • 18
  • 29
145
votes
17 answers

How do I install cURL on cygwin?

I tried to enable curl on cygwin but it says bash: curl: command not found How do I install curl on cygwin?
Drew LeSueur
  • 19,185
  • 29
  • 89
  • 106
145
votes
2 answers

How to get cURL to output only HTTP response body (JSON) and no other headers etc

I am using curl in a bash script to fetch the response of a service as below, response=$(curl -isb -H "Accept: application/json" "http://host:8080/some/resource") Service response is of json type and on browser I could perfectly fine…
Rishi
  • 5,869
  • 7
  • 34
  • 45
143
votes
8 answers

how to get the cookies from a php curl into a variable

So some guy at some other company thought it would be awesome if instead of using soap or xml-rpc or rest or any other reasonable communication protocol he just embedded all of his response as cookies in the header. I need to pull these cookies out…
thirsty93
  • 2,602
  • 6
  • 26
  • 26
137
votes
7 answers

Set cURL to use local virtual hosts

Using Apache or Ngnix I always create development sites based on real projects such as http://project1.loc which, after adding to my .hosts file, the browser has no problem using. However, when I attempt to make a cURL request…
Xeoncross
  • 55,620
  • 80
  • 262
  • 364
136
votes
4 answers

What is better, curl or wget?

Are they the same or not? Can certain things be done with one but not the other? What are those? Or is it, at the end of the day, a matter of familiarity?
flybywire
  • 261,858
  • 191
  • 397
  • 503
133
votes
29 answers

git clone error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054

I'm having trouble cloning a repo on git. I've been trying for to days and have tried quite a few solutions (in most the problem was slightly different but seemed to apply) but nothing has done anything to make a difference. I've tried switching off…
user8612746
  • 1,331
  • 2
  • 8
  • 4
133
votes
7 answers

How to include an '&' character in a bash curl statement

I'm trying to use curl in bash to download a webpage, but the & symbol in the URL isn't interpreted as a character as I would like. Any ideas on how I can convince bash that the symbol & is just a boring character and nothing special?
Chernoff
  • 2,494
  • 2
  • 20
  • 24
130
votes
2 answers

How do I preserve the remote filename when Downloading a file using curl

Possible Duplicate: How do I save a file using the response header filename with cURL I need to download many thousands of images in the format http://oregondigital.org/cgi-bin/showfile.exe?CISOROOT=/baseball&CISOPTR=0 If you paste that link in a…
Kyle Banerjee
  • 2,554
  • 4
  • 22
  • 30
128
votes
9 answers

Execute curl command within a Python script

I am trying to execute a curl command within a python script. If I do it in the terminal, it looks like this: curl -X POST -d '{"nw_src": "10.0.0.1/32", "nw_dst": "10.0.0.2/32", "nw_proto": "ICMP", "actions": "ALLOW", "priority": "10"}'…
Kiran Vemuri
  • 2,762
  • 2
  • 24
  • 40
127
votes
7 answers

Correct way to set Bearer token with cURL

I get my bearer token from an API end point and set the following: $authorization = "Bearer 080042cad6356ad5dc0a720c18b53b8e53d4c274" Next, I want to use cURL to access the secure endpoint however I am unsure on how or where to set the Bearer…
HappyCoder
  • 5,985
  • 6
  • 42
  • 73
125
votes
3 answers

Running cURL on 64 bit Windows

I'm new to cURL, just got it installed but it seems to only do what it feels like. I'm using the 64 bit version I got from here: http://curl.haxx.se/latest.cgi?curl=win64-ssl-sspi with installation instructions I found here:…
Jonathon Nordquist
  • 2,066
  • 4
  • 21
  • 23
124
votes
7 answers

send Content-Type: application/json post with node.js

How can we make a HTTP request like this in NodeJS? Example or module appreciated. curl https://www.googleapis.com/urlshortener/v1/url \ -H 'Content-Type: application/json' \ -d '{"longUrl": "http://www.google.com/"}'
Radoslav
  • 1,812
  • 3
  • 17
  • 27