<?php
error_reporting(E_ALL);
ini_set('display_errors','ON');
echo "Start<br>";
$data = "smv";
$url = "http://www.othersite.com/php/report.php";
$optional_headers = null;
$params = array('http' => array(
'method' => 'POST',
'reason' => $data
));
if ($optional_headers !== null) {
$params['http']['header'] = $optional_headers;
}
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
if (!$fp) {
echo "Problem with $url<br>";
}
$response = @stream_get_contents($fp);
if ($response === false) {
echo "Problem reading data from $url<br>";
}
?>
', var_export(stream_get_meta_data($fp), True), '
';<?php // RAY_curl_post_example.php
error_reporting(E_ALL);
function curl_post($url, $post_array, $timeout=2, $error_report=FALSE)
{
// PREPARE THE POST STRING
$post_string = '';
foreach ($post_array as $key => $val)
{
$post_string .= urlencode($key) . '=' . urlencode($val) . '&';
}
$post_string = rtrim($post_string, '&');
// PREPARE THE CURL CALL
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, FALSE);
curl_setopt($curl, CURLOPT_POST, TRUE);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_string);
curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
// EXECUTE THE CURL CALL
$htm = curl_exec($curl);
$err = curl_errno($curl);
$inf = curl_getinfo($curl);
curl_close($curl);
// ON FAILURE
if (!$htm)
{
// PROCESS ERRORS HERE
if ($error_report)
{
echo "CURL FAIL: $url TIMEOUT=$timeout, CURL_ERRNO=$err";
echo "<pre>\n";
var_dump($inf);
echo "</pre>\n";
}
return FALSE;
}
// ON SUCCESS
return $htm;
}
// USAGE EXAMPLE CREATES ASSOCIATIVE ARRAY OF KEY=>VALUE PAIRS
$args["name"] = 'Ray';
$args["email"] = 'Ray.Paseur@Gmail.com';
// ACTIVATE THIS TO SEE THE ARRAY OF ARGS
// var_dump($args);
// SET THE URL
$url = "http://LAPRBass.com/RAY_bounce_post.php";
// CALL CURL TO POST THE EATA
$htm = curl_post($url, $args, 3, TRUE);
if (!$htm) die("NO $url");
// SHOW WHAT CAME BACK
echo "<pre>";
echo htmlentities($htm);
<?php
error_reporting(-1);
ini_set('display_errors', 1);
echo "Start<br>";
$data = "smv";
$url = "http://www.softtester.com/php/report.php";
$optional_headers = null;
$params = array('http' => array(
'method' => 'GET',
'reason' => $data
));
if ($optional_headers !== null) {
$params['http']['header'] = $optional_headers;
}
$ctx = stream_context_create($params);
$fp = fopen($url, 'rb', false, $ctx);
var_export(stream_get_meta_data($fp));
if (!$fp) {
echo "Problem with $url<br>";
}
$response = stream_get_contents($fp);
if ($response === false) {
echo "Problem reading data from $url<br>";
} else
echo $response;
<?php
error_reporting(-1);
ini_set('display_errors', 1);
set_time_limit(0);
echo "Start<br>";
$data = "smv";
$url = "http://www.softtester.com/php/report.php";
$optional_headers = null;
$params = array('http' => array(
'method' => 'POST',
'reason' => $data
));
$optional_headers = 'Content-Length: 0';
if ($optional_headers !== null) {
$params['http']['header'] = $optional_headers;
}
$ctx = stream_context_create($params);
#$fp = @fopen($url, 'rb', false, $ctx);
$fp = fopen($url, 'rb', false, $ctx);
echo '<pre>', var_export(stream_get_meta_data($fp), True), '</pre>';
if (!$fp) {
echo "Problem with $url<br>";
}
#$response = @stream_get_contents($fp);
$response = stream_get_contents($fp);
if ($response === false) {
echo "Problem reading data from $url<br>";
}
?>
<?php // RAY_temp_curl_post_example.php
error_reporting(E_ALL);
function curl_post($url, $post_array, $timeout=2, $error_report=FALSE)
{
// PREPARE THE POST STRING
$post_string = '';
foreach ($post_array as $key => $val)
{
$post_string .= urlencode($key) . '=' . urlencode($val) . '&';
}
$post_string = rtrim($post_string, '&');
// PREPARE THE CURL CALL
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, FALSE);
curl_setopt($curl, CURLOPT_POST, TRUE);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_string);
curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
// EXECUTE THE CURL CALL
$htm = curl_exec($curl);
$err = curl_errno($curl);
$inf = curl_getinfo($curl);
curl_close($curl);
// ON FAILURE
if (!$htm)
{
// PROCESS ERRORS HERE
if ($error_report)
{
echo "CURL FAIL: $url TIMEOUT=$timeout, CURL_ERRNO=$err";
echo "<pre>\n";
var_dump($inf);
echo "</pre>\n";
}
return FALSE;
}
// ON SUCCESS
return $htm;
}
// USAGE EXAMPLE CREATES ASSOCIATIVE ARRAY OF KEY=>VALUE PAIRS
$args["reason"] = 'smv';
// ACTIVATE THIS TO SEE THE ARRAY OF ARGS
// var_dump($args);
// SET THE URL
$url = "http://www.softtester.com/php/report.php";
// CALL CURL TO POST THE EATA
$htm = curl_post($url, $args, 3, TRUE);
if (!$htm) die("NO $url");
// SHOW WHAT CAME BACK
echo "<pre>";
echo htmlentities($htm);
Is this what you are trying to achieve?