[請益] 使用POST方式將資料貼至ssl網站
我想作自動登入的程式(具有ssl的server)
在網址列上打入"https://xxx.xxx.xxx.xxx/xxx.asp?user=xxx&pwd=xxx
這樣的方式是可以login的
我嘗試將他寫成php但似乎有問題,得不到結果
<?
$pw = "user=xxx&pwd=xxx";
$url = "some url";
$user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
$tmp = curl_init();
curl_setopt($tmp, CURLOPT_POST, 1);
curl_setopt($tmp, CURLOPT_POSTFIELDS, $pw );
curl_setopt($tmp, CURLOPT_URL, $url);
curl_setopt($tmp, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($tmp, CURLOPT_USERAGENT, $user_agent);
curl_setopt($tmp, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($tmp, CURLOPT_HEADER, 1);
$content = curl_exec($tmp);
echo $content;
curl_close($tmp);
?>
請問上面的寫法有錯誤嗎@@?
跑完後沒有顯示任何畫面
if( $content = curl_exec($tmp) )也回傳false
對curl不太熟悉,煩請賜教
謝謝m(_ _)m
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 124.10.1.56
PHP 近期熱門文章
PTT數位生活區 即時熱門文章