If I have to create Web Services (REST/SOAP APIs) for Joomla based website. I have MySQL DataBase running with Joomla website and I wanted to create mobile apps for that.

By using same Database how I can create Rest/Soap web services? So if I write an article in Joomla site, it will display in mobile app as well.

I have few questions regarding this topic

  1. Should I use framework for this such as Slim Framework or other framework? (I know thats not a good idea because Joomla also runs a framework)
  2. How I can secure it?

  3. How to increase the performance?

Thanks in advance.

  • Are you really considering SOAP for WS? – Valentin Despa Feb 3 '16 at 21:21
  • @ValentinDespa thats why I asked :) – Joomler Feb 4 '16 at 5:18

Create a new php file (webapi.php) and save it to the root of your site.

Add in the required files to access the Joomla Framework like so:

define('_JEXEC', 1);

require_once $_SERVER['DOCUMENT_ROOT'].'/includes/defines.php';
require_once $_SERVER['DOCUMENT_ROOT'].'/includes/framework.php';

$app = JFactory::getApplication('site');

$JInput = JFactory::getApplication()->input;
$secretKey = $JInput->get('secretKey','','string');
$request_data = $JInput->get('request','','array');

Using the Joomla Framework allows you access to everything already in your database, no need for an external framework to do what Joomla is already built to do.

For encryption:

Have your mobile app pass a secret key and whatever other request data you may want to pass to query your database with.

Write some simple validation that will check your secret key against your site. Or for that matter use the secret key in your config file if you wanted to even though I don't recommend that. You can base64_encode they key on the mobile apps end then decode it back on your end. Or better still, HASH the key on the mobile apps end using a secret key, the check the value of the hash against your private key on the server side.

  • faced with 403 on joomla 1.5 , any solution? – Yuseferi Jun 5 '18 at 20:56
  • Not a clue, been a very long time since I have even looked at a 1.5 install. – Terry Carter Aug 29 '18 at 18:51
  • I've resolved that on commenting time, but I can't remember how right now :-) – Yuseferi Aug 31 '18 at 6:57

You can use com_ajax

Take a look at this: https://docs.joomla.org/Using_Joomla_Ajax_Interface

and also and example here: https://github.com/Joomla-Ajax-Interface/Ajax-Latest-Articles

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.