How to use Python to execute a cURL command?

For the sake of simplicity, you should consider using the Requests library. An example with JSON response content would be something like: import requests r = requests.get(‘https://github.com/timeline.json’) r.json() If you look for further information, in the Quickstart section, they have lots of working examples. For your specific curl translation: import requests url=”https://www.googleapis.com/qpxExpress/v1/trips/search?key=mykeyhere” payload = open(“request.json”) … Read more

curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number

* Uses proxy env variable http_proxy == ‘https://proxy.in.tum.de:8080’ ^^^^^ The https:// is wrong, it should be http://. The proxy itself should be accessed by HTTP and not HTTPS even though the target URL is HTTPS. The proxy will nevertheless properly handle HTTPS connection and keep the end-to-end encryption. See HTTP CONNECT method for details how … Read more

Setting Curl’s Timeout in PHP

See documentation: http://www.php.net/manual/en/function.curl-setopt.php CURLOPT_CONNECTTIMEOUT – The number of seconds to wait while trying to connect. Use 0 to wait indefinitely. CURLOPT_TIMEOUT – The maximum number of seconds to allow cURL functions to execute. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0); curl_setopt($ch, CURLOPT_TIMEOUT, 400); //timeout in seconds also don’t forget to enlarge time execution of php script self: set_time_limit(0);// to … Read more

How do I make a request using HTTP basic authentication with PHP curl?

You want this: curl_setopt($ch, CURLOPT_USERPWD, $username . “:” . $password); Zend has a REST client and zend_http_client and I’m sure PEAR has some sort of wrapper. But its easy enough to do on your own. So the entire request might look something like this: $ch = curl_init($host); curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Content-Type: application/xml’, $additionalHeaders)); curl_setopt($ch, CURLOPT_HEADER, 1); … Read more

How to send file contents as body entity using cURL

I believe you’re looking for the @filename syntax, e.g.: strip new lines curl –data “@/path/to/filename” http://… keep new lines curl –data-binary “@/path/to/filename” http://… curl will strip all newlines from the file. If you want to send the file with newlines intact, use –data-binary in place of –data

cURL error 60: SSL certificate: unable to get local issuer certificate

How to solve this problem: download and extract cacert.pem following the instructions at https://curl.se/docs/caextract.html save it on your filesystem somewhere (for example, XAMPP users might use C:\xampp\php\extras\ssl\cacert.pem) in your php.ini, put this file location in the [curl] section (putting it in the [openssl] section is also a good idea): [curl] curl.cainfo = “C:\xampp\php\extras\ssl\cacert.pem” [openssl] openssl.cafile … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)