How to catch cURL errors in PHP

You can use the curl_error() function to detect if there was some error. For example: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $your_url); curl_setopt($ch, CURLOPT_FAILONERROR, true); // Required for HTTP error codes to be reported via our call to curl_error($ch) //… curl_exec($ch); if (curl_errno($ch)) { $error_msg = curl_error($ch); } curl_close($ch); if (isset($error_msg)) { // TODO – Handle … Read more

HTTPS and SSL3_GET_SERVER_CERTIFICATE:certificate verify failed, CA is OK

It’s a pretty common problem in Windows. You need just to set cacert.pem to curl.cainfo. Since PHP 5.3.7 you could do: download https://curl.se/ca/cacert.pem and save it somewhere. update php.ini — add curl.cainfo = “PATH_TO/cacert.pem” Otherwise you will need to do the following for every cURL resource: curl_setopt ($ch, CURLOPT_CAINFO, “PATH_TO/cacert.pem”);

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

Look at http.request var options = { host: url, port: 80, path: ‘/resource?id=foo&bar=baz’, method: ‘POST’ }; http.request(options, function(res) { console.log(‘STATUS: ‘ + res.statusCode); console.log(‘HEADERS: ‘ + JSON.stringify(res.headers)); res.setEncoding(‘utf8’); res.on(‘data’, function (chunk) { console.log(‘BODY: ‘ + chunk); }); }).end();

How to POST JSON Data With PHP cURL?

You are POSTing the json incorrectly — but even if it were correct, you would not be able to test using print_r($_POST) (read why here). Instead, on your second page, you can nab the incoming request using file_get_contents(“php://input”), which will contain the POSTed json. To view the received data in a more readable format, try … Read more

Getting HTTP code in PHP using curl

First make sure if the URL is actually valid (a string, not empty, good syntax), this is quick to check server side. For example, doing this first could save a lot of time: if(!$url || !is_string($url) || ! preg_match(‘/^http(s)?:\/\/[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(\/.*)?$/i’, $url)){ return false; } Make sure you only fetch the headers, not the body content: @curl_setopt($ch, … Read more

PHP – SSL certificate error: unable to get local issuer certificate

Finally got this to work! Download the certificate bundle. Put it somewhere. In my case, that was c:\wamp\ directory (if you are using Wamp 64 bit then it’s c:\wamp64\). Enable mod_ssl in Apache and php_openssl.dll in php.ini (uncomment them by removing ; at the beginning). But be careful, my problem was that I had two … Read more

Execute bash script from URL

source <(curl -s http://mywebsite.example/myscript.txt) ought to do it. Alternately, leave off the initial redirection on yours, which is redirecting standard input; bash takes a filename to execute just fine without redirection, and <(command) syntax provides a path. bash <(curl -s http://mywebsite.example/myscript.txt) It may be clearer if you look at the output of echo <(cat /dev/null)

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