note 69309 added to ref.curl

From: Date: Thu, 31 Aug 2006 08:33:18 +0000
Subject: note 69309 added to ref.curl
Groups: php.notes 
Request: Send a blank email to php-notes+get-116531@lists.php.net to get a copy of this message
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 ---- Server IP: 203.16.234.19 Probable Submitter: 202.71.165.12 ---- X-Spam-Status: Yes, hits=7.4 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER, HEAD_ILLEGAL_CHARS autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/ref.curl.php Edit -- https://master.php.net/note/edit/69309 Del: integrated -- https://master.php.net/note/delete/69309/integrated Del: useless -- https://master.php.net/note/delete/69309/useless Del: bad code -- https://master.php.net/note/delete/69309/bad+code Del: spam -- https://master.php.net/note/delete/69309/spam Del: non-english -- https://master.php.net/note/delete/69309/non-english Del: in docs -- https://master.php.net/note/delete/69309/in+docs Del: other reasons-- https://master.php.net/note/delete/69309 Reject -- https://master.php.net/note/reject/69309 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#116531) next »