简体   繁体   English

CURL“无法打开流:已达到重定向限制”在本地有效,但在服务器上无效

[英]CURL “failed to open stream: Redirection limit reached” works local but not on server

I have a script that works on my local machine, on a shared server, on web browser, but not on VPS . 我有一个脚本可以在本地计算机,共享服务器,Web浏览器上运行, 但不能在VPS上运行

I use CURL to download a webpage's HTML, for example this url: 我使用CURL下载网页的HTML,例如以下URL:

https://www.yes.co.il/content/YesChannelsHandler.ashx?action=GetDailyShowsByDayAndChannelCode&dayValue=0&dayPartByHalfHour=37&channelCode=YSAL

It fails with an error: 它失败并显示错误:

failed to open stream: Redirection limit reached

The VPS php version is: PHP 5.5.9-1ubuntu4.3 VPS php版本为: PHP 5.5.9-1ubuntu4.3

Any ideas how to solve this issue? 任何想法如何解决这个问题?

Thanks! 谢谢!

Your VPS has a different max redirection limit then the other environments. 您的VPS具有与其他环境不同的最大重定向限制。 You should be able to increase it using the cUrl PHP option CURLOPT_MAXREDIRS. 您应该能够使用cUrl PHP选项CURLOPT_MAXREDIRS来增加它。

Assuming you are using the resource name $ch: 假设您正在使用资源名称$ ch:

curl_setopt($ch, CURLOPT_MAXREDIRS, 10);

Your version works locally, but not on the server. 您的版本在本地运行,但不能在服务器上运行。 And, it seems that you are accessing https://. 并且,似乎您正在访问https://。 So, try with: 因此,尝试:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

Also, find out how many redirection are happening, and if possible, give the last URL in the redirect. 另外,找出发生了多少重定向,并在可能的情况下提供重定向中的最后一个URL。

What about follow location setting? 追踪位置设定如何? Did you try? 你试过了吗?

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

相关问题 PHP - 无法打开流:达到重定向限制 - PHP - failed to open stream : redirection limit reached file_get_contents,无法打开流:达到重定向限制 - file_get_contents, failed to open stream: Redirection limit reached simplexml-load-file:无法打开流:已达到重定向限制 - simplexml-load-file : failed to open stream: Redirection limit reached get_headers()达到重定向限制,正在中止。 无法打开流:操作正在进行中 - get_headers() Redirection limit reached, aborting. failed to open stream: Operation now in progress 警告:file_get_contents:无法打开流:达到重定向限制,正在中止 - Warning: file_get_contents: failed to open stream: Redirection limit reached, aborting TYPO3 v7.6.19:solr PHP警告:无法打开流:已达到重定向限制 - TYPO3 v7.6.19: solr PHP Warning: failed to open stream: Redirection limit reached 达到SimpleXML重定向限制 - SimpleXML Redirection Limit Reached php:达到重定向限制 - php: Redirection limit reached 卷曲错误:无法连接到 <url> 端口8444:连接被拒绝,只能在本地运行,但不能在服务器上运行 - Curl Error : Failed to connect to <url> port 8444: Connection refused, works in local but not in server PHP fopen() 达到重定向限制错误 - PHP fopen() Redirection Limit Reached Error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM