Hi, I'm trying to write a script that will search for specific information from a php script that is serves xml from a website, and everything is working well except for one thing.
The website uses /options to look at previous pages. I'm not sure how to describe this, so I'll give an example: script.php?xml=true&/302 - would be opening page 302. However, when I type this into my script (using fputs($fc, "GET http://x.com/script.php?xml=true&/302 HTTP/1.1\r\nHost: x.com\r\n\r\n")), I get served the default page, as if the server isn't understanding the request.
If anyone could offer any ideas as to why that would be I'd be very grateful, as I'm relatively new to php, and don't see why this shouldn't be working.
Thanks, Dave
Site not understanding request sent by fputs?
Moderator: General Moderators
Re: Site not understanding request sent by fputs?
Don't forge headers when you don't know what you're doing.
Code: Select all
$xml = file_get_contents("http://x.com/script.php?xml=true&/302");Re: Site not understanding request sent by fputs?
Thanks, that works brilliantly. Can I ask for a more detailed explanation of what that function does that my script didn't, and how it did it? If it's just to do with headers, how did it find out which ones to send? etc.
I just want a deeper understanding of what is going on instead of always having to rely on functions that are already available. Thanks for the help
Dave
[EDIT] - Out of curiosity, I examined the headers/responses sent by the respective code.
Original code (fails):

Provided code (works):

The only difference I can see is that the server closes the connection on the working code, but I can't see why, as the submitted headers appear to be identical. If anyone has any ideas as to why that may be, please let me know.
Thanks, Dave
I just want a deeper understanding of what is going on instead of always having to rely on functions that are already available. Thanks for the help
Dave
[EDIT] - Out of curiosity, I examined the headers/responses sent by the respective code.
Original code (fails):

Provided code (works):

The only difference I can see is that the server closes the connection on the working code, but I can't see why, as the submitted headers appear to be identical. If anyone has any ideas as to why that may be, please let me know.
Thanks, Dave