Page 1 of 1
Reading data from an HTTPS Link
Posted: Tue May 19, 2009 5:41 pm
by andycain
Hi guys,
I have access to a secure server that contains schedules and lists amongst other things and I want to display this information on my own sites secure section via a PHP script.
The HTTPS url requires you to login. Can I pass the login information to the HTTPS server and download the content using the php script without having the user to type in the username / password combination?
This is the script I have so far. My server doesn't support cURL so I need a work around.
Code: Select all
<?php
$url = "https://secureserver.co.uk";
$user = "username";
$pass = "password";
$data = fopen ($url,r);
$calendar = fread ($data);
echo $calendar;
?>
Now clearly whenever I run this script I get a 401 Unauthroised error. This is because I don't know how to pass the credentials to the server.
I've been reading about secure sockets, digest authentication etc and it's not really making much sense!!
EDIT: I asked my webhost to install cURL. Their response in a nutshell: 'no'
Any ideas would be great!
Andy
Re: Reading data from an HTTPS Link
Posted: Tue May 19, 2009 6:36 pm
by Christopher
There is a class called Snoopy that does much of what cURL does.
Re: Reading data from an HTTPS Link
Posted: Wed May 20, 2009 7:29 am
by andycain
Okay.
I downloaded that from sourceforge and used this script....
Code: Select all
<?php
include ("Snoopy.class.php");
$snoopy = new Snoopy;
$snoopy->agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
$snoopy->referer = "http://www.83sqn.co.uk/secure pages/secureindex.htm";
$snoopy->rawheaders["Pragma"] = "no-cache";
//passwords
$snoopy->user = "Username";
$snoopy->pass = "Password";
$data = $snoopy->fetch("https://www.mysecureserver.co.uk");
echo $snoopy->results;
?>
This sends back a blank page. No error, no content. Nothing.
It works fine when I use an HTTP link.
Any thoughts?
Re: Reading data from an HTTPS Link
Posted: Wed May 20, 2009 7:45 am
by crazycoders
Does the snoppy class uses it's own internal mechanism to access external pages? If so, it's maybe not designed to use HTTPS.i
Re: Reading data from an HTTPS Link
Posted: Wed May 20, 2009 7:52 am
by andycain
I'm not sure. I've only heard about it today...
I've been googling this and not found many answers but some people have been saying it links with the cURL library which isn't installed on my server...hence why I'm using Snoopy.
Surley I would get an error back if this were the case?
Is there no way to pass HTTPS login credentials using fopen / fread ?
Re: Reading data from an HTTPS Link
Posted: Thu May 21, 2009 1:51 pm
by andycain
Anybody?
Re: Reading data from an HTTPS Link
Posted: Thu May 21, 2009 2:32 pm
by Christopher
Did you look in the Snoopy source? As I recall it is pretty easy to understand.
Re: Reading data from an HTTPS Link
Posted: Thu May 21, 2009 5:55 pm
by andycain
Yer I've looked in the snoopy source and it definatly needs cURL installed to work which puts me back to square one.
How do I access an HTTPS link using PHP without using cURL?
There must be a way surely?!
Re: Reading data from an HTTPS Link
Posted: Thu May 21, 2009 7:00 pm
by Christopher
First, Snoopy need the command line version of cURL installed -- not the extension. So you may try that. Otherwise you make need to make the call in a frame and get the frame contents using Javascript.
Re: Reading data from an HTTPS Link
Posted: Fri May 22, 2009 4:24 pm
by andycain
How would I use Javascript to access an HTTPS link?
Is it possible?
If so I'll look up how to do it myself unless anybody wants to let me be lazy and tell me how

Re: Reading data from an HTTPS Link
Posted: Tue May 26, 2009 11:54 am
by andycain
Any ideas anybody? I don't mean to pester but this problem is really bugging me!
Re: Reading data from an HTTPS Link
Posted: Tue May 26, 2009 2:27 pm
by kaisellgren
You could just use fsockopen(), although it requires plenty of coding from your side. You could try to look at PEAR.
Re: Reading data from an HTTPS Link
Posted: Thu May 28, 2009 3:37 am
by andycas
I need the same thing with snoopy. Im trying to fetch some info from xbox.com. So how would i log in with snoopy to this:
https://login.live.com/login.srf?
Could someone post example?