I am testing a simple API using cURL. This is a call from (php file) one Apache server (php file) to another Apache server . It is normal to test locally. But when I test my network PCs, it shows the following 403 error:
Access forbidden! You don't have permission to access the requested object. It is either read-protected or not readable by the server. If you think this is a server error, please contact the webmaster. Error 403
Codes for Caller Server (Server 1):
function apicall($request_url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $request_url); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $return = curl_exec($ch); curl_close($ch); return $return; } $request_url = 'http://192.168.1.205/api.php?cname=David'; $response = apicall($request_url);
Codes for the response server (server 2):
echo "Hello ".$_GET['cname'];
cURL is enabled for both Apache. So why? What should I do?
source share