当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Read joomla user information from android

问题描述:

I've a problem with a php script that accept POST request from an android client that send username and password to the script.

First it connect to the Joomla mySQL database and then read the user information.

This is the php code:

<?php

define( '_JEXEC', 1 );

define('JPATH_BASE', dirname(__FILE__) );

define( 'DS', DIRECTORY_SEPARATOR );

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

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

require('libraries/joomla/factory.php');

$mainframe =& JFactory::getApplication('site');

$mainframe->initialise();

$user =& JFactory::getUser();

$credentials = array();

$options = array();

$input = JFactory::getApplication()->input;

$name = $input->get('username', null);

$pass = $input->get('password', null);

$credentials['username'] = $name;

$credentials['password'] = $pass;

$result = False;

$result=JFactory::getApplication()->login($credentials,$options);

echo $fn;

echo $ln;

if ($result==False) {

$Log = "Not logged";}

else{

$Log = "Logged";}

$user->get('name');

$arr = array ('Statement'=>$Log,'User'=>$user);

echo json_encode($arr);

?>

I've used 'echo $fn' to check the POST connection and it works but it return me all the voices of json to null.

If I write my username and password into the php it works perfectly, if I use GET request the first time it return me json to null, the second time works.

Thanks.

分享给朋友:
您可能感兴趣的文章:
随机阅读: