I am trying to make a REST request to a external webserver by using this code
<?php
$user = 'USER';
$pass = 'PASS';
$data = "MYDATA"
$ch = curl_init('URL');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data))
);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_VERBOSE, true);
if(!($res = curl_exec($ch))) {
echo('[cURL Failure] ' . curl_error($ch));
}
curl_close($ch);
echo($res);
Now this is a CURL request, however i tried different methods to test my result and they all give me a 403 forbidden error response that i get from the webserver, however i do get a 200 response when i run it on any other webserver (localhost, webserver2, ...) Therefore i think there is something wrong with my webserver and it might be disallowing/caching the post parameters that i provide because sometimes it returns a 200 response but most of the times it returns the 403.
This is the response i get :
HTTP/1.1 403 Forbidden Accept-Ranges: bytes Content-Type: application/json; charset=UTF-8 Date: Sat, 26 Oct 2013 13:56:37 GMT Server: Restlet-Framework/2.1.3 Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept Content-Length: 77 Connection: keep-alive {"error":"ForbiddenOperationException","errorMessage":"Invalid credentials."}
It says Invalid credentials however i provide the correct credentials and i can confirm them because it is working on other servers.
Since this is a crucial part of my script that i use for clients to register i assume that there is something wrong with the post parameters.
I am running cpanel and uninstalled the following already:
- varnish
- apachebooster
i also recompiled php already and enabled curl and its dependencies but nothing seems to resolve my problem.
If more information is required then don't hesitate to ask me in the comments i will respond very quickly as i really need this.
any help is appreciated.
Kind regards Maxim