background image

}
fclose($fp);
?>
第二种方法是:使用 httpclient 类
PHP 代码
$pageContents = HttpClient::quickPost('http://example.com/someForm', array(
'name' => 'Some Name',
'email' => 'email@example.com'
));
使 用 httpclient 类 库 , 可 以 去 官 方 下 载 最 新 的 类 库 , 官 方 地 址 为 :
http://scripts.incutio.com/httpclient/index.php
附加一些点 php httpclient 的其他几个用法
静态方法获取网页:
PHP 代码
$pageContents = HttpClient::quickGet('http://example.com/');
Get 方法获取
PHP 代码
$client = new HttpClient('example.com');
if (!$client->get('/')) {
die('An error occurred: '.$client->getError());
}
$pageContents = $client->getContent();
带调试的 Get 方法获取
PHP 代码
$client = new HttpClient('example.com');
$client->setDebug(true);
if (!$client->get('/')) {
die('An error occurred: '.$client->getError());
}
$pageContents = $client->getContent();
带自动转向的 Get 方法
PHP 代码
$client = new HttpClient('www.amazon.com');
$client->setDebug(true);
if (!$client->get('/')) {
die('An error occurred: '.$client->getError());
}
$pageContents = $client->getContent();
检查页面是否存在
PHP 代码
$client = new HttpClient('example.com');
$client->setDebug(true);
if (!$client->get('/thispagedoesnotexist')) {
die('An error occurred: '.$client->getError());