From 6b8f6fedcd7140d3edb47fb788038b22a5be5bb7 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Fri, 11 Aug 2006 22:00:05 +0000 Subject: [PATCH] add example on how to send POST data using stream context opts. many thanks to Sara for the code git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@218006 c90b9560-bf6c-de11-be94-00142212c4b1 --- appendices/wrappers.xml | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/appendices/wrappers.xml b/appendices/wrappers.xml index 1e674a5a64..4d0cf86a6d 100644 --- a/appendices/wrappers.xml +++ b/appendices/wrappers.xml @@ -1,5 +1,5 @@ - + List of Supported Protocols/Wrappers @@ -202,6 +202,35 @@ foreach($meta_data['wrapper_data'] as $response) { ]]> + + Fetch a page and send POST data + + 'some content', + 'var2' => 'doh' + ) +); + +$opts = array('http' => + array( + 'method' => 'POST', + 'header' => 'Content-type: application/x-www-form-urlencoded', + 'content' => $postdata + ) +); + +$context = stream_context_create($opts); + +$result = file_get_contents('http://example.com/submit.php', false, $context); + +?> +]]> + + The stream allows access to the body of the resource; the headers are stored in the