在Asp.Net中,访问页面可通过下面的函数来完成,postData是需要Post指定url的数据:public string getHtml(string url, CookieContainer cookie, byte[] postData);在php中如何实现呢?是不是可以这样写呢?<?php
function getHtml($url,$tmpFile,$postData)
{
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
curl_setopt($ch, CURLOPT_COOKIEJAR, $tmpFile);
curl_setopt($ch, CURLOPT_COOKIEFILE, $tmpFile); 
if($postData!=NULL)
{
curl_setopt($ch, CURLOPT_POST, 1);  
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); 
}
$content=curl_exec($ch);  
curl_close($ch); 
return $content;
}
?>下面这两句是否都不能少呢?
curl_setopt($ch, CURLOPT_COOKIEJAR, $tmpFile);
curl_setopt($ch, CURLOPT_COOKIEFILE, $tmpFile); 只能通过临时文件吗?还有其他改进的方法吗?O(∩_∩)O谢谢啦~~~~~~