通过cURL和PHP登录oscommerce管理面板

通过cURL和PHP登录oscommerce管理面板,php,curl,admin,oscommerce,Php,Curl,Admin,Oscommerce,我试图通过cURL和PHP登录到oscommerce管理面板,我已经在post_数组中输入了正确的登录名和密码,但是我一直收到“错误:无效的管理员登录尝试”。我是否正确发送了post数据并保存了cookie? 这是我的密码: <?php $agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 ( .NET CLR 3.5.30729; .NET

我试图通过cURL和PHP登录到oscommerce管理面板,我已经在post_数组中输入了正确的登录名和密码,但是我一直收到“错误:无效的管理员登录尝试”。我是否正确发送了post数据并保存了cookie? 这是我的密码:

    <?php
$agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 ( .NET CLR 3.5.30729; .NET4.0E)';
$username = 'PromptUsername';
$password = 'PromptPassword';
$URL =  'http://www.example.com/admin/login.php'; //'http://www.example.com/admin/categories.php?cPath=21';
$path1 = 'cookies/';
$post_array = array(  
'username'=>'usernAme',
'password'=>'passw0rd'
);
$authURL = $URL.'?action=process';

// Login here
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $authURL);
curl_setopt($ch,CURLOPT_USERAGENT,$agent); 
curl_setopt($ch, CURLOPT_COOKIEJAR, realpath($path1.'cookies.txt') );
curl_setopt($ch, CURLOPT_COOKIEFILE, realpath($path1.'cookies.txt'));
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_REFERER, $URL);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_array));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  'method' => 'POST',
  "Authorization: Basic ".base64_encode("$username:$password")."\r\n",
));
$debug = curl_getinfo($ch, CURLINFO_HTTP_CODE);
var_dump($debug);
$store = curl_exec ($ch);
var_dump($store);
?>

您正在添加带有授权头的
\r\n
,这会扰乱服务器。把它们取下来

"Authorization: Basic ".base64_encode("$username:$password"),