0

2.5 Joomla Web サイトで動作する Android アプリケーション用のログイン システムを作成しようとしています。Androidアプリケーションが投稿データをphpファイルに送信するJoomlaプラグインを作成して、これを実行しようとしています。これにより、ユーザーが認証され、ログインの資格情報が正しいかどうかが確認されます。私は午後中ずっとこれを機能させようとしてきましたが、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 のインポートに関するこれら の他の質問をてきましたが、どれもうまくいきませんでした
:外部phpファイル、Joomlaで

だから私の簡単な質問は、どのように JFactory をインポートするか、少なくともこの状況でそれを回避するのですか? 質問にとても親切に答えてくれる私より頭が良いと感じている人なら誰でも:)

一般情報:

  • PHP 5.1.13を実行しています
  • ジュムラ 2.5
  • wamp サーバー (localhost) でのテスト
4

2 に答える 2

0

これを試して、

define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );//this is when we are in the root
define( 'DS', DIRECTORY_SEPARATOR );

require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
$db     = JFactory::getDbo();

それはうまくいきます、あなたは逃しましたJFactory::getApplication('site');

それが役に立てば幸い..

于 2013-09-28T09:45:24.630 に答える