简体   繁体   English

突然在PHP中访问被拒绝的cUrl

[英]Suddenly access denied cUrl in PHP

I used the following function to get access to an API (live working example) 我使用以下函数来访问API(实时工作示例)

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.halteverbotszonen.com/api/numbers');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$output = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

Since a few days (can't tell exactly when) it gives me a 403 error when executing the curl call. 由于几天(无法准确确定何时),它在执行curl调用时给出了403错误。 Accessing https://www.halteverbotszonen.com/api/numbers directly is possible. 可以直接访问https://www.halteverbotszonen.com/api/numbers I have not changed anything on any of the two servers, what could possibly cause this and where could I see that (any logs for this?) 我没有改变任何两台服务器上的任何东西,可能导致这种情况,我在哪里可以看到(任何日志?)

I have a second api where the same happens (accessible directly works, but not via curl call). 我有第二个api,同样的情况发生(可以直接访问,但不能通过curl调用)。 It's the same hoster, could they have changed something that does not allow incoming curl calls? 它是同一个主机,他们可能改变了一些不允许传入卷曲呼叫的东西吗?

Any hint appreciated 任何暗示赞赏

- Maybe due to https/http ?
- Maybe a different conf inside your apache/php ?
- Maybe the distant server banned your IP

:o :○

In most of cases, when something works and PAF another day didn't work anymore, it's a software update problem (like conf file) or network problem (like IP) or distant problem (like the server). 在大多数情况下,当某些东西工作并且PAF在另一天不再起作用时,它是软件更新问题(如conf文件)或网络问题(如IP)或远程问题(如服务器)。 I guess :D 我想:D

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM