Goodreads Developers discussion
      bugs
      >
    php file_get_contents fails
    
  
  
					date newest »
						  
						newest »
				
		 newest »
						  
						newest »
				 Can you try doing wget or curl? (cookies might be messing with this in the browser)
      Can you try doing wget or curl? (cookies might be messing with this in the browser)What's the response body?
 Michael wrote: "Can you try doing wget or curl? (cookies might be messing with this in the browser)
      Michael wrote: "Can you try doing wget or curl? (cookies might be messing with this in the browser)What's the response body?"
$response is blank because the function fails with the 400 error. I'm going to try curl but am having some issues getting it installed on my server VM. I may have to upgrade the OS first.
 Ok, thanks for trying that.
      Ok, thanks for trying that.Can you email me a sample url containing your key to support@goodreads.com (mention my name).
That would help me diagnose a little more.
 Michael wrote: "Ok, thanks for trying that.
      Michael wrote: "Ok, thanks for trying that.Can you email me a sample url containing your key to support@goodreads.com (mention my name).
That would help me diagnose a little more."
Done. Should be able to test curl tomorrow.
 Michael wrote: "Ok, thanks for trying that.
      Michael wrote: "Ok, thanks for trying that.Can you email me a sample url containing your key to support@goodreads.com (mention my name).
That would help me diagnose a little more."
Server upgrade was fairly painless; once curl was installed, it works. For future reference there is a drop-in function replacement for file_get_open at http://snipplr.com/view/51161/basic-c.... I think based one some other reading while waiting for the server to upgrade is that is likely the agent setting, which spoofs the web service into thinking it is a browser doing the calling. Strictly speaking, that shouldn't be necessary. But curl facilitates this parameter. At least that's my guess. File_get_open should work.


 
[function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 400 using some simple php, as follows:
$request="http://www.goodreads.com/book/title?t...
$response=file_get_contents($request);
I've verified that $request works when manually entered into a browser. Why might I be getting a 400 error and what might be the workaround?