我想爲我的2.5 Joomla網站的Android應用程序製作一個登錄系統。我正在嘗試通過製作一個Joomla插件來實現這一點,即Android應用程序將發佈數據發送到一個php文件,然後通過該文件對用戶進行身份驗證,以查看登錄憑據是否正確。我一直試圖在下午完成這項工作,但似乎我所有的導入JFactory的嘗試都失敗了。JFactory無法導入
我有下面的代碼,在第一次提到JFactory時出錯了。我嘗試導入它也不起作用。
<?php
//needed to be commented out otherwise the android application cannot send data to the file
//defined('_JEXEC') or die;
define('_JREQUEST_NO_CLEAN', 1);
define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);
if (file_exists(dirname(__FILE__) . '/defines.php')) {
include_once dirname(__FILE__) . '/defines.php';
}
if (!defined('_JDEFINES')) {
define('JPATH_BASE', dirname(__FILE__));
require_once JPATH_BASE.'/includes/defines.php';
}
require_once JPATH_BASE.'/includes/framework.php';
require_once JPATH_BASE.'/includes/helper.php';
require_once JPATH_BASE.'/includes/toolbar.php';
require JPATH_BASE.'/library/joomla/factory.php';
$email = $_POST['email'];
$password = $_POST['password'];
file_put_contents("Log.txt", "got data: ".$email." and ".$password);
$credentials->email = $email;
$credentials->password = $password;
$responce;
//error occurs here
$db = JFactory::getDbo();
...
?>
我已經看過有關導入JFactory這些問題,但他們都不是爲我工作:
- JFactory,JDatabase class not found in /var/www/joomla2.5/database.php
- Class 'JFactory' not found
- include Jfactory class in an external php file, Joomla
所以我簡單的問題是,我該怎麼辦導入JFactory或至少在這種情況下解決它?任何人都覺得比我聰明會是誰這麼好心來回答這個問題:)
一般資料:
- 運行PHP 5.1.13
- 的Joomla 2.5
- 測試WAMP的服務器上(本地主機)
我建議升級到PHP 5.3 – Laoneo