Jump to content

Connecting to external API from Processwire


modifiedcontent
 Share

Recommended Posts

I am trying to connect with an external API, from marketing automation application Mautic on the same server, from a template in Processwire, with something like this:

require '/serverpath/vendor/autoload.php';

use Mautic\Auth\ApiAuth;
use Mautic\MauticApi;

$initAuth = new ApiAuth();

This works in an empty test page outside of Processwire. Trying to use it from a template within Processwire I get this error:

Quote

Fatal Error: Uncaught Error: Class 'ApiAuth' not found in site/templates/session.php:43

#0 wire/core/TemplateFile.php (318): require()
#1 wire/core/Wire.php (394): TemplateFile->___render()
#2 wire/core/WireHooks.php (823): Wire->_callMethod('___render', Array)
#3 wire/core/Wire.php (465): WireHooks->runHooks(Object(TemplateFile), 'render', Array)
#4 wire/modules/PageRender.module (536): Wire->__call('render', Array)
#5 wire/core/Wire.php (397): PageRender->___renderPage(Object(HookEvent))
#6 wire/core/WireHooks.php (823): Wire->_callMethod('___renderPage', Array)
#7 /wire/c (line 43 of site/templates/session.php)

How can I make sure the script looks for Mautic's ApiAuth in the correct place? 

Mautic's autoload.php is included in the page successfully; I have checked that.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...