pfpfpf Posted August 3, 2018 Share Posted August 3, 2018 (edited) I am using PHP fsockopen to get data from a website and this has been working well until today. I am now getting a 200 response but it indicates "Redirecting..." Response follows: HTTP/1.1 200 OK Content-Type: text/html; charset=utf-8 Content-Length: 331 Expires: Fri, 03 Aug 2018 00:49:45 GMT Cache-Control: max-age=0, no-cache, no-store Pragma: no-cache Date: Fri, 03 Aug 2018 00:49:45 GMT Connection: close <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Redirecting</title> </head> <body> <h3> Redirecting... </h3> <p> If you are not redirected from this page. Please press the 'back' button on your browser. </p> <script> (function(){ history.go(-1); })(); </script> </body> </html> When I manually enter the URL in a browser then I get the correct information. When PHP accesses the page it gets the above. It there a way for PHP to follow such a redirect? Thanks. Edited August 3, 2018 by pfpfpf Quote Link to comment Share on other sites More sharing options...
requinix Posted August 3, 2018 Share Posted August 3, 2018 No, PHP cannot execute Javascript like that. The page is clearly trying to "redirect" you to the previous page you were visiting. That doesn't make sense with what you're saying. The URL you're fetching is wrong. But that aside, why are you using fsockopen and not file_get_contents? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.