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
242
votes
16 answers

Execute bash script from URL

Say I have a file at the URL http://mywebsite.example/myscript.txt that contains a script: #!/bin/bash echo "Hello, world!" read -p "What is your name? " name echo "Hello, ${name}!" And I'd like to run this script without first saving it to a file.…
Tristan
  • 2,617
  • 3
  • 15
  • 9
242
votes
19 answers

Why does cURL return error "(23) Failed writing body"?

It works ok as a single tool: curl "someURL" curl -o - "someURL" but it doesn't work in a pipeline: curl "someURL" | tr -d '\n' curl -o - "someURL" | tr -d '\n' it returns: (23) Failed writing body What is the problem with piping the cURL output?…
static
  • 8,126
  • 15
  • 63
  • 89
240
votes
8 answers

Getting HTTP code in PHP using curl

I'm using CURL to get the status of a site, if it's up/down or redirecting to another site. I want to get it as streamlined as possible, but it's not working well.
Aaran McGuire
  • 2,975
  • 3
  • 22
  • 26
240
votes
7 answers

How to POST JSON Data With PHP cURL?

Here is my code, $url = 'url_to_post'; $data = array( "first_name" => "First name", "last_name" => "last name", "email"=>"email@gmail.com", "addresses" => array ( "address1" => "some address", "city" => "city", …
user1463076
  • 2,715
  • 4
  • 16
  • 12
225
votes
10 answers

How can I enable cURL for an installed Ubuntu LAMP stack?

I have installed the Ubuntu LAMP stack. But cURL is not enabled, and neither can I can find the extension listed in the INI file. I added it manually, but it didn't work either. How should I enable cURL then?
Arshdeep
  • 4,281
  • 7
  • 31
  • 46
219
votes
2 answers

Assign output to variable in Bash

I'm trying to assign the output of cURL into a variable like so: #!/bin/sh $IP=`curl automation.whatismyip.com/n09230945.asp` echo $IP sed s/IP/$IP/ nsupdate.txt | nsupdate However, when I run the script the following happens: ./update.sh: 3: =[my…
Alex Bliskovsky
  • 5,973
  • 7
  • 32
  • 41
218
votes
15 answers

How to make remote REST call inside Node.js? any CURL?

In Node.js, other than using child process to make CURL call, is there a way to make CURL call to remote server REST API and get the return data? I also need to set up the request header to the remote REST call, and also query string as well in GET…
murvinlai
  • 48,919
  • 52
  • 129
  • 177
215
votes
5 answers

How to catch cURL errors in PHP

I am using PHP curl functions to post data to the web server from my local machine. My code is as follows: $c = curl_init(); curl_setopt($c, CURLOPT_URL, $url); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); curl_setopt($c, CURLOPT_POST,…
Harish Kurup
  • 7,257
  • 19
  • 65
  • 94
213
votes
5 answers

Making an API call in Python with an API that requires a bearer token

Looking for some help with integrating a JSON API call into a Python program. I am looking to integrate the following API into a Python .py program to allow it to be called and the response to be printed. The API guidance states that a bearer token…
user4657
  • 2,303
  • 2
  • 15
  • 9
210
votes
12 answers

HTTPS and SSL3_GET_SERVER_CERTIFICATE:certificate verify failed, CA is OK

I am using XAMPP for development. Recently I upgraded my installation of xampp from an old version to 1.7.3. Now when I curl HTTPS enabled sites I get the following exception Fatal error: Uncaught exception 'RequestCore_Exception' with message …
Josnidhin
  • 12,469
  • 9
  • 42
  • 61
206
votes
42 answers

What's the net::ERR_HTTP2_PROTOCOL_ERROR about?

I'm currently working on a website, which triggers a net::ERR_HTTP2_PROTOCOL_ERROR 200 error on Google Chrome. I'm not sure exactly what can provoke this error, I just noticed it pops out only when accessing the website in HTTPS. I can't be 100%…
Tristan G
  • 2,157
  • 2
  • 6
  • 10
198
votes
12 answers

https connection using CURL from command line

I am new to Curl and Cacerts world and facing a problem while connecting to a server. Basically, I need to test connectivity over https from one machine to another machine. I have a URL to which I need to connect from Machine A (a linux machine) I…
user1270392
  • 2,981
  • 4
  • 21
  • 25
182
votes
3 answers

Content-Type header [application/x-www-form-urlencoded] is not supported on Elasticsearch

I used to have ElasticSearch 5.2, and just upgraded to 6.0. I am trying to create an index template following guide here, but got error Content-Type header [application/x-www-form-urlencoded] is not supported My query is curl -X PUT…
Barry Leishman
  • 1,823
  • 2
  • 7
  • 7
180
votes
20 answers

cURL equivalent in Node.js?

I'm looking to use information from an HTTP request using Node.js (i.e. call a remote web service and echo the response to the client). In PHP I would have used cURL to do this. What is the best practice in Node?
slifty
  • 13,062
  • 13
  • 71
  • 109
179
votes
2 answers

How to properly handle a gzipped page when using curl?

I wrote a bash script that gets output from a website using curl and does a bunch of string manipulation on the html output. The problem is when I run it against a site that is returning its output gzipped. Going to the site in a browser works fine.…
BryanH
  • 5,826
  • 3
  • 34
  • 47