I have a script that works on my local machine, on a shared server, on web browser, but not on VPS .
I use CURL to download a webpage's HTML, for example this 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
Any ideas how to solve this issue?
Thanks!
Your VPS has a different max redirection limit then the other environments. You should be able to increase it using the cUrl PHP option CURLOPT_MAXREDIRS.
Assuming you are using the resource name $ch:
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
Your version works locally, but not on the server. And, it seems that you are accessing 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.
What about follow location setting? Did you try?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.