Automating HTTP Authentication problem

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
machek
Forum Newbie
Posts: 1
Joined: Sat Oct 28, 2006 2:53 pm

Automating HTTP Authentication problem

Post by machek »

Automating HTTP Authentication was easy think before Microsoft made MS04-004 Cumulative Security Update for Internet Explorer (832894). It is not possible do things like http://name:password@site.com any more.

I have web cam, and for access to web cam is requiring Http Authentication. I tried hard, but I didn't find working solution. Idea was to do something like this, to do Automating HTTP Authentication:

Code: Select all

$sAuth = base64_encode("webcam:webcam"); 
$sHTTP = "GET /cgi-bin/video.jpg HTTP/1.1\r\n
Accept: image/jpeg\r\n
Connection: close\r\n
Host: 192.168.1.10\r\n";

$hSocket = fsockopen("192.168.1.10", 80); 
fputs($hSocket, $sHTTP.$sAuth."\r\n"); 
fclose($hSocket);
Or simililar
http://www.informit.com/articles/articl ... 55423&rl=1

Server(Web cam) is just returning HTTP/1.0 200 OK, but when I try to click to view image, immediately is again asking for authorization.

Nothing is working. Does anybody know easy way in PHP how to sort out problem Automating HTTP Authentication?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Code: Select all

$contents = file_get_contents('http://name:password@site.com');
php's http wrapper still supports n:p@site
Post Reply