首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >PHP CURL获取403禁止

PHP CURL获取403禁止
EN

Stack Overflow用户
提问于 2020-05-21 07:47:15
回答 2查看 755关注 0票数 1

我安装了一个新的带有PHP版本7.4.3的ubuntu服务器v20,用来从一个旧的带有PHP版本7.0的ubuntu服务器v18上移动一个web应用程序,当我在新服务器上执行CURL REST API GET时,我得到了一个403错误。下面是带有错误debug的代码,许可证密钥的一部分已为post修改。我还没能找到任何与搜索现有帖子相关的内容。提前感谢你的帮助

代码语言:javascript
运行
复制
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;
代码语言:javascript
运行
复制
<!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
EN

回答 2

Stack Overflow用户

发布于 2020-05-21 20:35:21

在我的例子中,这是一个DNS问题。license.cmadsystems.com解析为错误的IP地址。

票数 1
EN

Stack Overflow用户

发布于 2020-05-21 08:12:09

代码语言:javascript
运行
复制
echo file_get_contents(
    "http://license.cmadsystems.com?lic=P9xP1o7USRLkS591cFzBbLSmI9ZTtvR7xgfr86dtYiCZuhy"
);

返回

代码语言:javascript
运行
复制
"status":200,
"status_message":"Licensed",
"data":{
        "Lic_End":null,
        "Lic_Device":0,
        "Lic_MOH":0,
        "Lic_Info":null
    }
}
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61924806

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档