Post form-data


function post_data($url, $data, $opt_headers = null)
{
$parameters = array('http' => array(
'method' => 'POST',
'content' => $data
));
if ($opt_headers !== null)
{
$parameters['http']['header'] = $opt_headers;
}
$context = stream_context_create($parameters);
$f = @fopen($url, 'rb', false, $context);
if (!$f)
{
echo "Problem with $url\n";
}
$response = @stream_get_contents($f);
if ($response === false)
{
echo "Problem reading data from $url\n";
}
return $response;
}