PHP4 HTTP Post without cURL

Posted by Luke on Stack Overflow See other posts from Stack Overflow or by Luke
Published on 2010-03-19T14:37:30Z Indexed on 2010/03/19 14:41 UTC
Read the original article Hit count: 567

Filed under:
|
|
|
|

I have the following code that works on PHP5 to send a HTTP POST without using cURL. I would like this to work on PHP 4.3.0 and above:

$opts = array('http' =>
    array(
        'method'  => 'POST',
        'header'  => "Content-type: application/x-www-form-urlencoded\r\n" . "Content-Type: application/json\r\n",
        'content' => $query
    )
);
$context  = stream_context_create($opts);
$result = file_get_contents($url, false, $context);

HTTP context is only supported on PHP5. Is there anyway to make this work with PHP 4.3.0 - I need a fallback method if PHP5 or cURL is not installed.

© Stack Overflow or respective owner

Related posts about php

Related posts about curl