function do_post_request($url, $data, $optional_headers = null) {
$request = new HttpRequest($url, HttpRequest::METH_POST);
$request->setBody($data);
$response = $request->send();
return $response->getBody();
}
This piece of code doesn't seem to be working, and seems to crash my script. I don't know if its because I don't have the php_http module, but is there an equivalent I can use?
For instance curl? I have tried curl, but I don't know much about it, and with curl I got a "bad request" returned from the server I was trying to connect to with a 400 status.
Anything would be good
Thanks
Tom
Edit:
function do_post_request($url, $data, $optional_headers = null) {
$request = new HttpRequest($url, HttpRequest::METH_POST);
$request->setBody($data);
$response = $request->send();
return $response->getBody();
}
echo "before";
$response = do_post_request($url, $data);
echo "After";
Doing that makes "before" appear on the page. But no "After".
After managing to turn error reporting on I get this:
Fatal error: Class 'HttpRequest' not found in /home/sites/ollysmithwineapp.com/public_html/mellowpages/geocode.php on line 25
So I need another way to do the HTTP Request.