note 126346 added to function.stream-context-create

From: Date: Wed, 18 Aug 2021 05:41:47 +0000
Subject: note 126346 added to function.stream-context-create
Groups: php.notes 
Request: Send a blank email to php-notes+get-216799@lists.php.net to get a copy of this message
To open HTTPS stream I could only work it out using both HTTP and SSL context options… Thus something like: <?php $postdata = http_build_query( array( 'var1' => 'some content', 'var2' => 'doh' ) ); $opts = array( 'ssl' => array( 'verify_peer' => false, 'verify_peername' => false // Ideally use instead // 'cafile' => 'path Certificate Authority file on local filesystem' ), 'http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded'."\r\n". '' 'content' => $postdata ) ); $context = stream_context_create($opts); $result = file_get_contents('https://example.com/submit.php', false, $context); // A good friend when it fails: var_dump($http_response_header); ?> ---- Server IP: 45.112.84.4 Probable Submitter: 45.112.85.242 (proxied: 2001:7e8:c803:2e00:fcab:d7d0:9c0b:903e) ---- Manual Page -- https://php.net/manual/en/function.stream-context-create.php Edit -- https://main.php.net/note/edit/126346 Del: integrated -- https://main.php.net/note/delete/126346/integrated Del: useless -- https://main.php.net/note/delete/126346/useless Del: bad code -- https://main.php.net/note/delete/126346/bad+code Del: spam -- https://main.php.net/note/delete/126346/spam Del: non-english -- https://main.php.net/note/delete/126346/non-english Del: in docs -- https://main.php.net/note/delete/126346/in+docs Del: other reasons-- https://main.php.net/note/delete/126346 Reject -- https://main.php.net/note/reject/126346 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#216799) next »