note 69309 deleted from ref.curl by betz

From: Date: Thu, 31 Aug 2006 17:53:24 +0000
Subject: note 69309 deleted from ref.curl by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-116554@lists.php.net to get a copy of this message
Note Submitter: marcus at techie-blogs dot com ---- For curl to perform HTTP Basic Authentication, it is easy to pass –user to the curl command, but harder with libcurl. Suspect there is an attribute that can be set, but I monitor a multitude of web sites through some perl scripts and libcurl. I did n’t want to have to modify my wrapper scripts, which mesh perl hashes with the code that drives curl (via libcurl). I do allow for headers though, having needed to pass different things through, like HTTP_REFERER, LAST_MODIFIED, etc. Therefore I just needed to pass the HTTP BASIC Authentication through as a header. This is how to do it in php: <?php $url="http://www.techie-blogs.com"; $header[] = "Authorization: Basic YWRtaW46YWRtaW4"; // admin:admin base64 encoded $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); ... ?> For further details see my post, where I do a more thorough run through with perl. Plus provide an online tool to do the base64 encoding. http://www.techie-blogs.com/wordpress/?p=166

« previous php.notes (#116554) next »