Aud*_*sen 32
您可以使用file_get_contents().
PHP手册在这里有一个很好的例子.这只是从手册中复制过来的:
$postdata = http_build_query(
array(
'var1' => 'some content',
'var2' => 'doh'
)
);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
$result = file_get_contents('http://example.com/submit.php', false, $context);
Run Code Online (Sandbox Code Playgroud)
您可以使用stream_context_create和file_get_contents
<?php
$context_options = array (
'http' => array (
'method' => 'POST',
'header'=> "Content-type: application/x-www-form-urlencoded\r\n"
. "Content-Length: " . strlen($data) . "\r\n",
'content' => $data
)
);
?>
$context = stream_context_create($context_options);
$result = file_get_contents('http://www.php.net', false, $context);
Run Code Online (Sandbox Code Playgroud)
Daf*_*aff -1
如果您已经在使用 Zend Framework,您应该尝试您提到的Zend_Http_Client:
$client = new Zend_Http_Client($host, array(
'maxredirects' => 3,
'timeout' => 30));
$client->setMethod(Zend_Http_Client::POST);
// You might need to set some headers here
$client->setParameterPost('key', 'value');
$response = $client->request();
Run Code Online (Sandbox Code Playgroud)