note 74431 added to function.stream-context-create
| From: | chris dot vigelius at gmx dot net | Date: | Wed, 11 Apr 2007 12:34:33 +0000 |
| Subject: | note 74431 added to function.stream-context-create | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-125290@lists.php.net to get a copy of this message | ||
It seems that the authorization example given below by"php at charlesconsulting dot com"
does NOT work with PHP 5.2.1, since the 'header' option will be simply ignored if it is
not an array (but a string).
The following works:
$url = 'http://protectedstuff.com';
$auth = base64_encode('user:password');
$header = array("Authorization: Basic $auth");
$opts = array( 'http' => array ('method'=>'GET',
'header'=>$header));
$ctx = stream_context_create($opts);
file_get_contents($url,false,$ctx);
See also http://bugs.php.net/bug.php?id=41051
----
Server IP: 212.124.37.9
Probable Submitter: 217.233.246.179
----
Manual Page -- http://www.php.net/manual/en/function.stream-context-create.php
Edit -- https://master.php.net/note/edit/74431
Del: integrated -- https://master.php.net/note/delete/74431/integrated
Del: useless -- https://master.php.net/note/delete/74431/useless
Del: bad code -- https://master.php.net/note/delete/74431/bad+code
Del: spam -- https://master.php.net/note/delete/74431/spam
Del: non-english -- https://master.php.net/note/delete/74431/non-english
Del: in docs -- https://master.php.net/note/delete/74431/in+docs
Del: other reasons-- https://master.php.net/note/delete/74431
Reject -- https://master.php.net/note/reject/74431
Search -- https://master.php.net/manage/user-notes.php