So I have tested this with fiddler as well as Rest Console and Advanced Rest Console everything works just fine there, but when I run in from cURL I get either a connection timed out error or can't connect to host. Url's are the same, headers are the same, content body is the same. I just don't get it. EDIT: WITHOUT AUTHORIZATION TURNED ON ON THE SERVER THE CODE WORKS JUST FINE
Almost 5 hours stuck here, here's the code:
function getLicenses() {
$license = new LicenseConnector();
$curl = curl_init();
$headers = array(
'Authorization: Bearer 12345...',
'Content-Type: application/x-www-form-urlencoded'
);
$myPost = 'RequestingAgency=Woo&AcctEmail=&LengthOfLic=365&Demo=on';
curl_setopt_array( $curl, array(
curl_setopt($curl, CURLOPT_URL, 'http://example.com/api/serialnumbers/getnewserial'),
curl_setopt( $curl, CURLOPT_POST, 1 ),
curl_setopt( $curl, CURLOPT_POSTFIELDS, $myPost ),
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 ),
curl_setopt($curl, CURLOPT_HEADER, 1),
curl_setopt($curl, CURLINFO_HEADER_OUT, true),
curl_setopt( $curl, CURLOPT_HTTPHEADER, $headers )
) );
$result = curl_exec( $curl );
$results = json_decode( $result );
if ( curl_errno( $curl ) ) {
echo 'error:' . curl_error( $curl );
} else {
echo $results;
}
curl_close( $curl );
}
Then I run the function...