I am trying to get PHP Curl working using the following code: I own the domain that is using the api and I can make any changes to the server that it is running on.
<?php
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
$data = array("username" => "derped", "authid" => "987654321", "ipaddress" => "1.2.3.4", "apikey" => "1234567829");
$data_string = json_encode($data);
$url = 'https://www.somedomain.com/test/api.php';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: Content-Type: text/html'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
if(curl_exec($ch) === false)
{
echo curl_error($ch);
}
else
{
echo 'ok';
}
curl_close($ch);
$received = json_decode($result);
$check = $received->{'good'};
echo $result;
echo $check;
?>
Curl returns the error: Peer reports it experienced an internal error. When I curl the domain itself (https://www.somedomain.com) it returns the same error. Even when I use curl via the terminal it returns the 35 error, but when I try to curl the domain without HTTPS it returns the 302 found but since my domain is https only this will not be the solution, it just echos the move page. I know this has something todo with curl using https but https://www.google.com works so I dont know where to start...