-1

Here is the code I am using:

$content = file_get_contents('https://professor-oak.com/CardOrders/ItemDetails.asp?IID=6837');
echo $content;

I have been using this code for about two years now and it just stopped working. I need help to know how to get it working again.

I have tried using urlencode. -no help. I tried switching cURL. - no help. I tried cURL sumilating a broswer. -no help.

I have used the following for reference:

PHP CURL & HTTPS

php curl: how can i emulate a get request exactly like a web browser?

Can a cURL based HTTP request imitate a browser based request completely?

PHP file_get_contents() returns "failed to open stream: HTTP request failed!"

I also used

http://seositecheckup.com/seo-audit/robotstxt-test/professor-oak.com/CardOrders/ItemDetails.asp?IID=6837

to check for robots.txt.

Please help.

Community
  • 1
  • 1
  • 2
    You need to figure out why it fails, do you control the other site? Have you tried curling the site from cli on the server? If the other site is not yours then maybe they have blocked your servers IP. – JimL Jun 03 '16 at 20:52
  • I do not control the other site. I could be blocked, but how do i check? – Justin Phenix Jun 03 '16 at 20:54
  • I mentioned one method of checking in the first comment – JimL Jun 03 '16 at 20:56
  • It's possible that the host of the site has added code to deny access to http calls that don't include an accepted User-Agent. You might try faking a browser user agent in a curl request to see if that works....but...you know...if they don't want you scraping the data...probably shouldn't scrape the data... – whitwhoa Jun 03 '16 at 20:56
  • are you able to get value from other urls? say `echo file_get_contents('http://www.google.com');` – Shadi Shaaban Jun 03 '16 at 20:58
  • If you are able to get content from other sites - you can fix the issue in multiple ways. But the only way I'd recommend would be to contact the site in question and explain what you're doing and why they should unblock you. – JimL Jun 03 '16 at 21:02
  • I have spoken with the owner of the site and have permission. Yes I can echo file_get_contents('http://www.google.com'); – Justin Phenix Jun 04 '16 at 15:47

1 Answers1

-1

You probably got blocked by them - just used your code and all seems to be good. One thing you might want to check is your log to see if any other details pop up.

UPDATE: you can test from a different server to check if you got blocked, probably the easiest way..

Alberto
  • 880
  • 5
  • 15