News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Wez Furlong's Blog:
HTTP POST from PHP, without cURL
November 15, 2006 @ 10:09:00

In an effort to get streams more out in the, er, mainstream, Wez Furlong has posted an example of some code for a common operation many use cURL for - posting to a remote script - but with streams.

Every time I search for the code snippet that allows you to do an HTTP POST request, I don't find it in the manual and resort to reading the source. So, here's an example of how to send a POST request with straight up PHP, no cURL.

The example uses stream_context_create, fopen, stream_get_contents and an Exception to send off the message from an inputted array to the remote server. Smaller things, like the Content-length header on the request, are automatically handled by the wrapper functionality. You can check out this page for more information on the wrapper functionality.

2 comments voice your opinion now!
http post without curl stream context contents exception http post without curl stream context contents exception


blog comments powered by Disqus

Similar Posts

PHPMaster.com: REST - Can You do More than Spell It? Part 3

Job Posting: Rapp Collins Worldwide (recruiter) Seeks Senior PHP Developer (Dallas, Tx)

Job Posting: Open Source Staffing Seeks a PHP5 Developer (New York, NY)

Job Posting: Veedow Seeks Senior PHP Developer/Architect (London, UK)

99Points.info: Youtube Style Share Button With URL Shortening using CURL, jQuery and PHP


Community Events





Don't see your event here?
Let us know!


developer series language refactor laravel opinion interview api unittest podcast community list code introduction symfony2 release framework threedevsandamaybe testing install

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework