Hi,
I'm not a PHP expert, buit I've got a script which needs changing from fopen() to curl()
The code in question is as follows:
Is anyone able to help me?
TIA
Andy
I'm not a PHP expert, buit I've got a script which needs changing from fopen() to curl()
The code in question is as follows:
Code:
function req_post($url, $data, $optional_headers = null) {
$params = array('http' => array(
'method' => 'POST',
'content' => $data
));
if ($optional_headers !== null) {
$params['http']['header'] = $optional_headers;
}
$ctx = stream_context_create($params);
$fp = fopen($url, 'rb', false, $ctx);
if (!$fp) {
throw new Exception("Problem with $url");
}
$response = @stream_get_contents($fp);
if ($response === false) {
throw new Exception("Problem reading data from $url");
}
return $response;
}
Is anyone able to help me?
TIA
Andy