나는 PHP에서 curl로 joomla 2.5에 원격으로 액세스하려고합니다. 나중에 나도 새로운 콘텐츠를 만들고 싶지만, 지금은 로그인에 문제가 있습니다. 나에겐 새로운 컬이기 때문에 내가 뭘 잘못하고 있는지 모른다. 다음 메시지가 나타납니다 : "세션이 만료되었습니다. 다시 로그인하십시오." 여기까지 내 코드가 있습니다 :Joomla 2.5 로그인 curl
$url = "http://localhost/joomla25/administrator/";
$cookie = "tmp/cookie".time().".txt";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_URL, $url);
ob_start();
$page = curl_exec ($ch);
curl_close ($ch);
unset($ch);
//get hidden inputs
preg_match_all("(<input type=\"hidden\" name=\"return\" value=\"(.*)\" />)siU", $page, $matches1);
preg_match_all("(<input type=\"hidden\" name=\"(.*)\" value=\"1\" />)iU", $page, $matches2);
$return = trim($matches1[1][0]);
$key = trim($matches2[1][0]);
$param = 'username='.urlencode("admin")."&passwd=".urlencode("admin")."&lang=&option=com_login&task=login&return=".urlencode($return)."&".urlencode($key)."=1";
$fp = fopen($cookie,"w");
fclose($fp);
//login
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_TIMEOUT, 40);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
ob_start();
$page2 = curl_exec ($ch);
ob_end_clean();
curl_close ($ch);
unset($ch);
echo $page2;
어떤 생각이 잘못된가요? 도와 주셔서 감사합니다!
당신은 나에게 아이디어를주었습니다. 내일 내가이 자동 로그인 플러그 인을 시도 할 것이다 http://extensions.joomla.org/extensions/access-a-security/authentication-cloud-based/10508 – warriorslo