我正在用cURL測試簡單的API。從另一個Apache服務器(另一個php文件)調用一個Apache Server(的一個php文件),。可以在本地進行測試。但是,當我用我的網絡PC測試,它顯示以下403錯誤:cURL在Apache顯示..「訪問被禁止!錯誤403」
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
代碼爲來電服務器(服務器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);
代碼爲應答服務器(服務器2)是:
echo "Hello ".$_GET['cname'];
cURL在兩個Apache的。所以爲什麼?我需要做什麼?
'禁止訪問!您無權訪問請求的對象。它是讀取保護的或不可讀的服務器。「不是一個明確的信息?它是你自己的服務器,你正在查詢或第三方? –