file_get_contents cookie?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Pyro In A Cage
Forum Newbie
Posts: 10
Joined: Mon Jul 17, 2006 4:27 pm

file_get_contents cookie?

Post 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.
aos24
Forum Newbie
Posts: 9
Joined: Tue Feb 06, 2007 4:37 pm

Post by aos24 »

You might want to check out CURL, which supports this kind of functionality.
Pyro In A Cage
Forum Newbie
Posts: 10
Joined: Mon Jul 17, 2006 4:27 pm

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I do hope you have the permission of the owners of the site you are pulling this information from.
Pyro In A Cage
Forum Newbie
Posts: 10
Joined: Mon Jul 17, 2006 4:27 pm

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Pyro In A Cage
Forum Newbie
Posts: 10
Joined: Mon Jul 17, 2006 4:27 pm

Post 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.
Pyro In A Cage
Forum Newbie
Posts: 10
Joined: Mon Jul 17, 2006 4:27 pm

Post 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?
Post Reply