Page 1 of 1

file_get_contents cookie?

Posted: Fri Feb 09, 2007 9:45 pm
by Pyro In A Cage
I am trying to use file_get_contents to get the contents of a members-only webpage. Because the website is members-only, the contents of the webpage obviously changes for each user. Is there any way to give the server a cookie, so that it logs into the website before getting the contents? I will be posting to a form to login.

For example:
If I wanted to check my PMs on this website, I would need to login first to do so. How would I go about telling the server to login, and then get the contents of the private messages HTML output? Without doing this, the file_get_contents function (Or whichever function used) would just return the "Please login" message, instead of the list of messages.

Posted: Fri Feb 09, 2007 9:55 pm
by aos24
You might want to check out CURL, which supports this kind of functionality.

Posted: Fri Feb 09, 2007 10:27 pm
by Pyro In A Cage
Thank you very much, that looks like it will work. But it is very complicated, and I don't know how it works. I looked at the manual, but am still confused.

Would you mind giving me an example of how to use it to do what I need?

Posted: Fri Feb 09, 2007 11:23 pm
by feyd
I do hope you have the permission of the owners of the site you are pulling this information from.

Posted: Sat Feb 10, 2007 1:11 am
by Pyro In A Cage
If I wanted legal advice, I would not have come to a programming forum. Do you contact your ISP every time you check your E-Mail with a third-party E-Mail client such as outlook or thunderbird? Do you contact google everytime you view their website with firefox or internet explorer? How about asking permission from your webhost before you use FlashFXP or WS_FTP to upload your files? I very highly doubt that you would answer yes to any of those questions. So why would I ask permission to write a client to ease access of information which I access on a daily basis?

What I am writing is simply a proxy, and it does not record or publish the information.

Back on topic: Will aos24, or any other helpful member here please give me an example of using CURL? I have tried to figure it out, but am having a very hard time. I would very much appreciate an example.

Posted: Sat Feb 10, 2007 1:04 pm
by feyd
Pyro In A Cage wrote:What I am writing is simply a proxy, and it does not record or publish the information.
Had you said this I would not have commented. We have to cover our own rears when users ask for such things because they can be illegal.

As for examples of cURL, there are many floating around. The major ones you will require are for the options governing cookies and posting.

Snoopy may be of interest too.

Posted: Sat Feb 10, 2007 1:35 pm
by Pyro In A Cage
Thank you. I'm sorry that I responded with such hostility. It frustrates me when people try to tell me things like that, but I know your just trying to help.

I have to go to work right now, but when I get back I will check out Snoopy. Thank you for your help.

Posted: Sun Feb 11, 2007 12:32 pm
by Pyro In A Cage
I checked out snoopy, but can't figure it out either. Will you please give me an example of how to use it?