CakeFest 2025 Madrid: The Official CakePHP Conference

Voting

: nine minus eight?
(Example: nine)

The Note You're Voting On

sp0n9e at gmail dot com
18 years ago
Here's a very simple way to do posts easily without need of cURL or writing an http request by hand using the tcp:// wrapper. I like using contexts just because of their ubiquity and the lack of an optional library such as cURL (though one of the more popular libraries).

<?php

$options
= array(
'http'=>array(
'method'=>"POST",
'header'=>
"Accept-language: en\r\n".
"Content-type: application/x-www-form-urlencoded\r\n",
'content'=>http_build_query(array('foo'=>'bar'))
));

$context = stream_context_create($options);

fopen('http://www.example.com/',false,$context);

?>

<< Back to user notes page

To Top