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
124
votes
10 answers

curl: (6) Could not resolve host: application

Getting url: (6) Could not resolve host: application error after this command : curl -i -H 'Content-Type: application/json' -d '{"Code":"FR","Name":"France"}' http://127.0.0.1:8080/countries Full error log: curl: (6) Could not resolve host:…
Yeahia2508
  • 7,526
  • 14
  • 42
  • 71
123
votes
20 answers

How can I download a single raw file from a private github repo using the command line?

On the CI server, I want to fetch a config file that we maintain on Github so it can be shared between many jobs. I'm trying to get this file via curl, but these approaches both fail (I get a 404): # As advised by the oAuth docs curl -H…
Matt Gibson
  • 14,616
  • 7
  • 47
  • 79
122
votes
9 answers

How to send line break with curl?

I've tried the following to send a line break with curl, but \n is not interpreted by curl. curl -X PUT -d "my message\n" http://localhost:8000/hello How can I send a line break with curl?
deamon
  • 89,107
  • 111
  • 320
  • 448
122
votes
4 answers

Save cookies between two curl requests

I know that using cURL I can see my received cookies / headers by using curl --head www.google.com And I know that I can add headers to my request using curl --cookie "Key=Value" www.google.com I am currently working on testing an issue which…
Matt Clark
  • 27,671
  • 19
  • 68
  • 123
122
votes
7 answers

Curl: Fix CURL (51) SSL error: no alternative certificate subject name matches

I am new to CURL world, coming from Windows + .NET domain. Trying to access Rest API for basic authentication at http://www.evercam.io/docs/api/v1/authentication. curl -X GET https://api.evercam.io/v1/... \ -u {username} Don't know how to use this…
theGeekster
  • 6,081
  • 12
  • 35
  • 47
122
votes
2 answers

PHP CURL DELETE request

I'm trying to do a DELETE http request using PHP and cURL. I have read how to do it many places, but nothing seems to work for me. This is how I do it: public function curl_req($path,$json,$req) { $ch = curl_init($this->__url.$path); $data =…
Bolli
  • 4,974
  • 6
  • 31
  • 47
122
votes
4 answers

PHP cURL vs file_get_contents

How do these two pieces of code differ when accessing a REST API? $result = file_get_contents('http://api.bitly.com/v3/shorten?login=user&apiKey=key&longUrl=url'); and $ch =…
Salvador Dali
  • 214,103
  • 147
  • 703
  • 753
121
votes
12 answers

PHP cURL HTTP CODE return 0

I dont understand when I echo $httpCode I always get 0, I was expecting 404 when I change $html_brand into a broken url. Is there anything that I miss or do not know of? Thanks. //check if url exist $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,…
Ardeus
  • 1,921
  • 3
  • 17
  • 26
120
votes
6 answers

How to call cURL without using server-side cache?

Is there a way to tell cURL command not to use server's side cache? e.g; I have this curl command: curl -v www.example.com How can I ask curl to send a fresh request to not use the cache? Note: I am looking for an executable command in the terminal.
tokhi
  • 21,044
  • 23
  • 95
  • 105
120
votes
3 answers

How to use curl to get a GET request exactly same as using Chrome?

I have a web api http://something.com/api and I want to use GET to get the response body. This is my command: curl "http://something.com/api" Of course, it fails and gives an error message. When I use Chrome and input the above url, everythings…
wdetac
  • 2,712
  • 3
  • 20
  • 42
120
votes
8 answers

Python request with authentication (access_token)

I am trying to use an API query in Python. From the command line I can use curl like so: curl --header "Authorization:access_token myToken" https://website.example/id This gives some JSON output. myToken is a hexadecimal variable that remains…
user1895406
  • 1,383
  • 2
  • 9
  • 10
120
votes
9 answers

curl.h no such file or directory

I installed curl this command (i use Ubuntu): sudo apt-get install curl When I test simple program using g++ test.cpp #include #include int main(void) { CURL *curl; CURLcode res; curl = curl_easy_init(); if(curl)…
user1518451
  • 1,767
  • 6
  • 23
  • 26
119
votes
4 answers

How do I set up curl to permanently use a proxy?

How can I set up "curl" to permanently use a proxy server in the terminal?
Ben
  • 4,609
  • 6
  • 21
  • 13
119
votes
7 answers

CURL alternative in Python

I have a cURL call that I use in PHP: curl -i -H 'Accept: application/xml' -u login:key "https://app.streamsend.com/emails" I need a way to do the same thing in Python. Is there an alternative to cURL in Python? I know of urllib but I have no idea…
Gaurav Sharma
  • 4,032
  • 14
  • 46
  • 72
118
votes
11 answers

How to get file_get_contents() to work with HTTPS?

I'm working on setting up credit card processing and needed to use a workaround for CURL. The following code worked fine when I was using the test server (which wasn't calling an SSL URL), but now when I am testing it on the working server with…
James Simpson
  • 13,488
  • 26
  • 83
  • 108