这是用于登录 joomla 网站的文件。
// a super-stripped down 2-leg oauth server/client example
function getLogin($userid, $psswrd) {
$app = JFactory::getApplication();
jimport('joomla.user.authentication');
jimport('joomla.session.session');
$auth = &JAuthentication::getInstance();
$session = &JFactory::getSession();
$session->set('name', "value");
$ssn_name = $session->get('name');
$sessionDetails = array(
'State' => $session->getState(),
'Expire' => session->getExpire(),
'Token' => $session->getToken(),
'FormToken' => $session->getFormToken(),
'Name' => $session->getName(),
'Id' => $session->getId(),
'getStores' => $session->getStores(),
'isNew' => $session->isNew());
$username = $userid;
$password = $psswrd;
$credentials = array(
'username' => $username,
'password' => $password);
$options = array();
$response = $auth->authenticate($credentials, $options);
if ($response->status == JAUTHENTICATE_STATUS_SUCCESS) {
$response->status = true;
$sessionDetails['loginStatus'] = $loginStatus = $app->login($credentials, $options);
return $sessionDetails;
}
else {
$response->status = false;
return 'testFalse';
}
}
现在我们使用 localhost 调用它
$client = new nusoap_client("http://domain-name/site-name/nusoap/remoteLogin.php");
$error = $client->getError();
if ($error) {
echo "<h2>Constructor error</h2><pre>" . $error . "</pre>";
}
$result = $client->call("getLogin", array(
"userid" => "admin",
"password" => "test"));
在上述项目中创建此会话后,并在数据库中使用新条目对其进行更新。但仍然无法登录网站。谁能帮我。
谢谢