【发布时间】:2016-10-25 08:25:25
【问题描述】:
我使用了来自此参考的以下代码:https://stackoverflow.com/a/2288181/4819200
<?php
//http://domain.com/script/script.php?username=username&passwd=password
define( '_JEXEC', 1 );
define('JPATH_BASE', '../' );
define( 'DS', DIRECTORY_SEPARATOR );
require_once('../configuration.php');
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'factory.php' );
/* Create the Application */
$mainframe =& JFactory::getApplication('site');
jimport('joomla.plugin.helper');
$credentials = array();
$credentials['username'] = JRequest::getVar('username', '', 'method', 'username');
$credentials['password'] = JRequest::getVar('passwd', '', 'method', 'passwd');
//perform the login action
$error = $mainframe->login($credentials);
$user = JFactory::getUser();
//now you are logged in
$mainframe->logout();
//now you are logged out
现在,问题
它在 Joomla 2.3 版本中工作,在 3.4 版本中停止工作。 现在,它没有从 $mainframe =& JFactory::getApplication('site'); 行返回。
你可以建议我最新版本的代码。
注意:我不是 joomla 人。但是,我研究过一些 PHP 框架。
【问题讨论】:
标签: web-services login joomla