Quantcast
Channel: Joomla! Forum - community, help and support
Viewing all articles
Browse latest Browse all 1944

Joomla! 5.x Coding • Re: AI Support Chat Integration with Joomla

$
0
0
Hi,

Thanks so much for the links.

What I'm most interested in is the integration of a 3rd party service with Joomla.

How would you authenticate Joomla users into your 3rd party app?

What I've come up with so far is to just:

Code:

define('_JEXEC', 1);define('JPATH_BASE', __DIR__); // Assuming this script is in the root of your Joomla installationrequire_once JPATH_BASE . '/includes/defines.php';require_once JPATH_BASE . '/includes/framework.php';// Get the Joomla application instance$app = JFactory::getApplication('site');// Get the current user object$user = JFactory::getUser();// Check if the user is logged inif ($user->guest) {    // User is not logged in    $userData = null;} else {    // User is logged in, retrieve user details    $userData = array(        'id' => $user->id,        'name' => $user->name,        'username' => $user->username,        'email' => $user->email        // Add any other user details you need    );}// Encode user data to JSON$userJson = json_encode($userData);
To show the logged in user information. I then just retrieve this into the react chat component via an api.

I'm not sure this is the correct way of it there is a proper API for integrating 3rd party components in Joomla now.

The key integration points are:

Authentication within Joomla and within 3rd party app (written in NodeJS and has an OAuth API).
Can Joomla authenticate users via OAuth or can that be built on top of a 3rd party plugin?
Can Joomla API show all the pages created with it's content and metadata?

At the moment I'm getting the menu items but I'd prefer to get actual data and not have to crawl each menu URL over HTTP.

Code:

$nexai = new Nexai(apiKey);$query = $dbo->getQuery(true);$query->select($dbo->quoteName(array('id', 'title', 'alias')));$query->from($dbo->quoteName('#__menu'));$query->where($dbo->quoteName('published') . ' = 1'); // Assuming you only want published pages$dbo->setQuery($query);$results = $dbo->loadObjectList();if ($results) {    echo "<ul>";    foreach ($results as $page) {        $url = JRoute::_('index.php?Itemid=' . $page->id);        $nexai->add($url, ['title' => $title]);    }    echo "</ul>";}

Statistics: Posted by nexai — Sat Apr 27, 2024 4:33 pm



Viewing all articles
Browse latest Browse all 1944

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>