Re: Authenicate a connection to remote server.
| From: | Chris Lee | Date: | Tue, 16 Oct 2001 17:34:21 +0000 |
| Subject: | Re: Authenicate a connection to remote server. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-71240@lists.php.net to get a copy of this message | ||
look into fread() and fwrite() your going to have todo this manually, just
like they are in perl.
--
Chris Lee
lee@mediawaveonline.com
"Len Coonan" <len_coonan@yahoo.com> wrote in message
news:20011016122937.6506.qmail@pb1.pair.com...
Hi, I am running a site and have got access to a news provider that will
allow me to display news headlines on my site that link to the articles on
their site. My problem is that they use HTTP Authentication to enable me to
access their files automatically. I know I can use fopen to open files
remotely, but how do I authenicate myself first.
They have provided me with a perl script as follows.
In order to automate the process of authenticating and downloading, one
needs to have some skills in perl scripting. One could very easily
write a small perl script that uses the LWP perl module for user
authentication. As an example piece of code:
use LWP::UserAgent;
my $ua = new LWP::UserAgent;
my $req = new HTTP::Request 'GET', 'http://news.news.com.au/finance.html';
$req->authorization_basic('userid', 'password');
my $result = $ua->request($req)->as_string;
This allows one to embed the username and password assigned to them into
a script that will complete the authentication process for them. From
here one simply needs to parse the returned file and extract the links
that are given. These links can be used in whichever way seen fit.
My question is, can I do this with PHP, and if so, could someone please
point me in the right direction.
thanks
len.