cURL — cookies and sessions

To understand CURLOPT_COOKIESESSION, you need to know a couple of things about cookies. Cookies have expiration dates that are set by the website that issues the cookie. If an expiration date of a cookie has passed, the browser/client will not send it, and it will be deleted by the client. If a cookie is set … Read more

Saving file using curl and PHP

did you want something like this ? function get_file($file, $local_path, $newfilename) { $err_msg = ”; echo “<br>Attempting message download for $file<br>”; $out = fopen($local_path.$newfilename,”wb”); if ($out == FALSE){ print “File not opened<br>”; exit; } $ch = curl_init(); curl_setopt($ch, CURLOPT_FILE, $out); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_URL, $file); curl_exec($ch); echo “<br>Error is : “.curl_error ( $ch); curl_close($ch); … Read more

Using curl in php with client certificate and private key in separate files

Here is a PHP script with a literal translation of your command line call: <?php $data = “var1=value1&var2=value2&…”; $url = “https://www.somesite.com/page”; $keyFile = “key.pem”; $caFile = “ca.pem”; $certFile = “client.pem”; $certPass = “xxxxxx”; // Initialise cURL $ch = curl_init($actualUrl); // The -d option is equivalent to CURLOPT_POSTFIELDS. But… // PHP’s libcurl interface does not implement … Read more

Can I do a CURL request to the same server?

Be aware that if you’re issuing the CURL request to your own site, you’re using the default session handler, and the page you’re requesting via CURL uses the same session as the page that’s generating the request, you’ll run into a deadlock situation. The default session handler locks the session file for the duration of … Read more

upload multiple files to php server using curl command line

The trick is to name the file uploading parameters unique. curl -F “[email protected]” -F “[email protected]” http://localhost:8888/web/Upload.php This will show up in the $_FILES superglobal as $_FILES[‘image’] and $_FILES[‘image2’]. To make the files grouped under one $_FILES index you need to name the parameters as arrays: curl -F “image[][email protected]” -F “image[][email protected]” http://localhost:8888/web/Upload.php