cURL – How to send and fetch data in WordPress

BACKGROUND After the user on domain1 clicks a link to domain 2, I need to send also the user-data (username,email,..) from server1/domain1 to server2/domain2 and to save it temporary in the server2/database. Both are wordpress websites. CURRENT WORK Lets say, $url=”http://my-domain2.com”; So far I found out, that cURL can do this job: function curlTest($url, $fields){ … Read more

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, true); curl_setopt($c, CURLOPT_POSTFIELDS, $data); $result = curl_exec($c); if (curl_exec($c) === false) { echo “ok”; } else { echo “error”; } curl_close($c); Unfortunately … Read more

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 protected]”, “addresses” => array ( “address1” => “some address”, “city” => “city”, “country” => “CA”, “first_name” => “Mother”, “last_name” => “Lastnameson”, “phone” => “555-1212”, “province” => “ON”, “zip” => “123 ABC” ) ); $data_string = json_encode($data); $ch=curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, … Read more

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

I’ve been researching for hours, but I don’t seem to find a solution. I’ve tried every single solution I’ve found. We’re running WordPress 5.4 with PHP v7.4 in a Windows 2019 server that’s behind an intranet in a Fortune 500 company (ie. Microsoft.com). I mention the Fortune 500 bit because we’re behind a firewall that … Read more