Welcome, Guest
Username: Password: Remember me

TOPIC: Using JFactory stuff in custom API

Using JFactory stuff in custom API 12 Oct 2016 11:04 #14632

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 15
As part of my component I have a custom API that acts as a webhook for an external system. This system sends POST data to the webhook which reads it and takes action

However for simplicity, I would really like to be able to utilise some of the Joomla functionlity i.e

JMailer (rather than having to call standalone phpmailer)
Jtext (so I can reuse language constants with he core mailing system)


and of course last but not least

JCook components, so I can use the easy method of calling a model and updating / adding a record

What headers do I need to add on my standalone page (if at all possible) to able to use the above. I have considered just creating a menu item into full Joomla and building the webhook stuff into that, but its a bit messy and would prefer a cleaner standalong solution like I have currnetly underway
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla
The administrator has disabled public write access.

Using JFactory stuff in custom API 12 Oct 2016 12:33 #14633

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 15
Got it
define( '_JEXEC', 1 );
define( 'JPATH_BASE', realpath(dirname(__FILE__).'/../../../../' )); // POint at the site root relative to where this code is.. in this case back a few driectories
require_once ( JPATH_BASE .'/includes/defines.php' );
require_once ( JPATH_BASE .'/includes/framework.php' );
require_once ( JPATH_BASE .'/configuration.php' ); // Database and mailer stuff
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla
The administrator has disabled public write access.

Using JFactory stuff in custom API 12 Oct 2016 17:43 #14634

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
Glad to be of service :P

This might be helpfu also or for future codingl: docs.joomla.org/How_to_create_a_stand-al...the_Joomla!_Platform
The administrator has disabled public write access.
The following user(s) said Thank You: MorganL

Using JFactory stuff in custom API 12 Oct 2016 20:26 #14635

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 15
Great share

I always knew the Joomla! platform had been designed to allow external sites to use parts of it, but just never tried. Now I have a great little standalone API that is using the mailer, jfactory and the language files of one of my components easily. Impressive tech which excites me for future mobile RESTful api.
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla
The administrator has disabled public write access.
Time to create page: 0.070 seconds

Get Started