$fields = array(
'__VIEWSTATE'=>'0IZf2tvjZxs7aeq7Tx7mFkZBB62iWgsCq3zbL%2BTnYZZ%2FXfeXgvDJNEEd3b3Z7COD',
'__EVENTVALIDATION'=>'YAJy6SEjjCbcu4df21JN%2BhAtGvApqKxJhDeS%2FE5s24EVBRHYEIqypa9hS%2BdTo%2FS%2F%2By8GO8Zu%2FS0%3D',
'Login1%24UserName'=>urlencode($StuNo),
'Login1%24Password'=>urlencode($StuPwd),
'Login1%24LoginButton'=>'%E7%99%BB%E5%85%A5'
);//POST的東西
foreach($fields as $key=>$value)
{
$fields_string .= $key.'='.$value;
if(sizeof($fields)-1!=$count)
$fields_string.="&";
}//組成POST STRING
$curl = curl_init("YOUR REQUEST URL");
$ckfile = tempnam ("/tmp", "CURLCOOKIE");//建立Cookie文件
curl_setopt($ch, CURLOPT_COOKIEJAR, "./cookie.txt");//寫入指定的Cookie
curl_setopt($curl, CURLOPT_POST, 1);//post資料給指定網頁
curl_setopt($curl, CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.2; zh-TW; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5");//UserAgent
$Result = curl_exec($curl);//Html String
curl_close($curl);
星期三, 12月 09, 2009
用PHP 做HTTP Request
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言
留個話吧:)