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
91
votes
4 answers

How to ignore invalid SSL certificate errors in Guzzle 5

This should be an easy thing to do. I can find plenty of references to how to do it in Guzzle 3, but they don't work in Guzzle 5. What I am doing so far: $this->client = new GuzzleClient(['defaults' => [ 'verify' => 'false' ]]); When I send a…
Gnuffo1
  • 3,478
  • 11
  • 39
  • 53
91
votes
8 answers

How to insert data into elasticsearch

I am new to Elasticearch, and I have been trying for 2 days to insert some data into Elasticearch. I found on Google that there are many pages to help to create an index (I am not clear about "index", does it mean "insert" in other terms?) Then many…
user1162069
90
votes
11 answers

Curl Certificate Error when Using RVM to install Ruby 1.9.2

RVM is running into a certificate error when trying to download Ruby 1.9.2. It looks like curl is having a certificate issue but I am not sure how to bypass it. I have included the exact error info below. $ rvm install 1.9.2 Installing Ruby from…
Will Dennis
  • 1,045
  • 1
  • 10
  • 12
90
votes
9 answers

curl: (6) Could not resolve host: google.com; Name or service not known

when I try to load a web page to terminal it gives curl: (6) Could not resolve host error. I have internet in my PC and trying from my home internet connection. So as I there is no any proxy involve here. [root@localhost kevin]# curl…
Nayana Adassuriya
  • 23,596
  • 30
  • 104
  • 147
90
votes
16 answers

Best way to manage long-running php script?

I have a PHP script that takes a long time (5-30 minutes) to complete. Just in case it matters, the script is using curl to scrape data from another server. This is the reason it's taking so long; it has to wait for each page to load before…
kbanman
  • 4,223
  • 6
  • 32
  • 40
90
votes
13 answers

PHP cURL error code 60

Whilst trying to setup a php environment on windows (using wamp) to use the Amazon PHP SDK, when i try to run a sample test I get the following error: Fatal error: Uncaught exception 'cURL_Exception' with message 'cURL resource: Resource id #10;…
Ciaran
  • 1,139
  • 2
  • 11
  • 14
90
votes
3 answers

Can I call curl_setopt with CURLOPT_HTTPHEADER multiple times to set multiple headers?

Can I call curl_setopt with CURLOPT_HTTPHEADER multiple times to set multiple headers? $url = 'http://www.example.com/'; $curlHandle = curl_init($url); curl_setopt($curlHandle, CURLOPT_HTTPHEADER, array('Content-type:…
hakre
  • 193,403
  • 52
  • 435
  • 836
89
votes
6 answers

Pipe output of cat to cURL to download a list of files

I have a list URLs in a file called urls.txt. Each line contains 1 URL. I want to download all of the files at once using cURL. I can't seem to get the right one-liner down. I tried: $ cat urls.txt | xargs -0 curl -O But that only gives me the…
Finch
  • 1,741
  • 3
  • 15
  • 15
89
votes
3 answers

curl_exec printing results when I don't want to

I am using the following code: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_TIMEOUT, 12); $result = curl_exec($ch); curl_close ($ch); However it's printing the results straight away. Is it possible to put…
Oliver Bayes-Shelton
  • 6,135
  • 11
  • 52
  • 88
89
votes
4 answers

Is there a way to discover all endpoints of a REST API?

I'm wondering if its possible to programmatically discover all the endpoints of a particular API. So for example if I GET this URL with a browser or curl: https://api.twitter.com/1.1/ I might get something like this as a JSON…
4m1r
  • 12,234
  • 9
  • 46
  • 58
89
votes
26 answers

SSL backend error when using OpenSSL

I was trying to install pycurl in a virtualenv using pip and I got this error ImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (none/other) I read some documentation saying that "To fix this,…
helloworld2013
  • 3,094
  • 5
  • 19
  • 26
89
votes
2 answers

Is there any way to get curl to decompress a response without sending the Accept headers in the request?

Is there any way to get curl to decompress a response without sending the Accept-encoding headers in the request? I'm trying to debug an issue where the order of the Accept-encoding headers may be relevant, but I also need to know what the response…
89
votes
2 answers

cURL code in PHP dumps output to the page

How do I hide the output from curl in PHP? My code as it stands is the following: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_USERPWD, $pass); $result =…
mrpatg
  • 10,001
  • 42
  • 110
  • 169
87
votes
5 answers

How to get response using cURL in PHP

I want to have a standalone PHP class where I want to have a function which calls an API through cURL and gets the response. Can someone help me in this? Thanks.
87
votes
8 answers

How to install php-curl in Ubuntu 16.04

Upgraded to Ubuntu 16.04 and facing problem after installing PHP5. Installed PHP-5 with following: sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt-get upgrade sudo apt-get install php5.5 # for PHP 5.5 Trying to install…
Govind Samrow
  • 9,981
  • 13
  • 53
  • 90