簡體   English   中英

PHP CURL GET 403 禁止

[英]PHP CURL GET 403 forbidding

I have installed a new ubuntu server v20 with PHP Version 7.4.3 to move a web application from an older ubuntu server v18 with PHP Version 7.0 and I am getting a 403 error on the new server when performing a CURL REST API GET. Bellow 是帶有錯誤調試的代碼,部分許可證密鑰已針對帖子進行了修改。 我無法在現有帖子中找到與此搜索相關的任何內容。 我在這里先向您的幫助表示感謝

ob_start();
$out = fopen('php://output', 'w');

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "http://license.cmadsystems.com?lic=P9xP1o7USRLkS591cFzBbLSmI9ZTtvR7xgfr86dtYiCZuhy",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0",
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_VERBOSE => true,
  CURLOPT_STDERR => $out,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);
    $err = curl_error($curl);

curl_close($curl);

fclose($out);
$debug = ob_get_clean();


echo $response;
echo $err;
echo $debug;
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access this resource.</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>
*   Trying 216.250.121.144:80...
* TCP_NODELAY set
* Connected to license.cmadsystems.com (216.250.121.144) port 80 (#0)
> GET /?lic= P9xP1o7USRLkS591cFzBbLSmI9ZTtvR7xgfr86dtYiCZuhy HTTP/1.1
Host: license.cmadsystems.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0
Accept: */*
Accept-Encoding: deflate, gzip, br
Content-Type: application/json

* Mark bundle as not supporting multiuse
< HTTP/1.1 403 Forbidden
< Content-Type: text/html; charset=iso-8859-1
< Transfer-Encoding: chunked
< Connection: keep-alive
< Keep-Alive: timeout=15
< Date: Wed, 20 May 2020 23:45:29 GMT
< Server: Apache
< Content-Encoding: gzip
< 
* Connection #0 to host license.cmadsystems.com left intact

就我而言,這是一個 DNS 問題。 license.cmadsystems.com 解析到錯誤的 IP 地址。

echo file_get_contents(
    "http://license.cmadsystems.com?lic=P9xP1o7USRLkS591cFzBbLSmI9ZTtvR7xgfr86dtYiCZuhy"
);

退貨

"status":200,
"status_message":"Licensed",
"data":{
        "Lic_End":null,
        "Lic_Device":0,
        "Lic_MOH":0,
        "Lic_Info":null
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM