streams gem 
Was reminded today of a gem from the streams extension - sending a POST message and getting its results. We could do it using cURL or sockets - but why work that hard. Being lazy does have its advantages after all.
Now I could make up an example for this - but why when the manual has such a nice one (though it is a bit buried in the manual on the HTTP/HTTPS wrapper page):
[php]
< ?php
$postdata = http_build_query(
array(
'var1' => ’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);
?>
[/php]
September 18th, 2007 at 7:05 am
thanks for this. i am already thinking of using this… hehe being lazy has its advantages…
September 18th, 2007 at 10:49 am
He, nearly as simple as
http_post_fields(”http://example.com/submit.php”, array(”var”=>”val”));
;P
October 3rd, 2007 at 1:34 am
While I’ve often used streams, I’m also a fan of context for doing HTTP posts as well
March 20th, 2008 at 3:01 am
bookmark you thx
March 20th, 2008 at 3:49 am
nice work man 10x