プログラムからPOSTする

PEARのHTTP_Requestを使ってフォームを介さずにPOSTデータを送信するサンプル。*1

hoge.php(データ送信側)

<?php
error_reporting(E_ALL);
require_once 'HTTP/Request.php';

$o_http = &new HTTP_Request('hoge1.php');
$o_http->setUrl('http://hoge.com/');
$o_http->setMethod(HTTP_REQUEST_METHOD_POST);
$o_http->addPostData('a', 'A');
$o_http->addPostData('b', 'B');
$o_http->addPostData('c', 'C');
$o_http->addPostData('d', 'D');
$o_http->addPostData('e',  array('E', 'EE', 'EEE', 'EEEE') );

if( !PEAR::isError( $o_http->sendRequest() ) )
{
	$response = $o_http->getResponseBody();
}
else
{
	$response = 'error';
}

error_reporting(E_ALL|E_STRICT);
print $response;

hoge1.php(データ受信側)

<?php
print "<pre>";
print_r($_POST);
print "</pre>";