Reply to Re: Login via php code on an external page

Your name:

Reply:


Posted by NC on 03/02/07 16:01

On Mar 1, 5:23 am, "Andrea" <andr...@tin.it> wrote:
>
> I have to do a php script that daily surf a webpage (I do it with
> crontab) and collect some data.
> The proble is that to access that webpage I have to do a login.
....
> How can I do it???

Before you do anything else, you need to understand what HTTP headers
are and how they work. Basically, here's what usually happens during
form-based authentication:

1. The authentication script receives a POST request including, among
other things, a login name and a password. It checks the login
name
and password against a database and, if check is successful, sends
to the client one or more cookies signifying the success.
2. The client receives the cookies and starts requesting protected
pages, including those cookies with every request.

You can emulate both of these actions either with cURL or by using
fsockopen(). First, you need to access the authentication page and
get the cookies, then, you can request the actual data by sending
out a GET request including those cookies. Be aware that sometimes
the authentication is a two-step process; the authentication script
checks credentials and, if they are OK, redirects the client to
another script that sets the cookies.

If you have Firefox, you can actually see all the readers being
exchanged between client and server using Live HTTP Headers plugin:

http://livehttpheaders.mozdev.org/

Cheers,
NC

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация