0
我試圖使用PHP腳本通過POSTING登錄到另一個網站(本例中爲Moodle安裝)。這個PHP代碼通過流發送POST數據有什麼問題?
此代碼似乎部分工作。問題是隻有第一個參數被接收端識別。對於下面顯示的代碼,僅識別「用戶名」參數。但是,如果您切換'用戶名'和'密碼'的順序,以便首先列出'密碼',那麼僅使用$ _POST ['密碼']識別「密碼」。
$postdata = http_build_query(
array(
'username' => $currentUser,
'password' => $userPassword,
)
);
$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($loginURL, false, $context);
任何想法爲什麼只有第一個參數被識別?
它適用於我的機器_(tm)_。 – Wrikken 2010-10-21 16:07:51