Mautic Community Forums

Pushing data from Mautic to Other external APIs

Dears,

I’m very new to Mautic and we started to using it recently.
We came across with a requirement to push contact data (on specific cases) to a sales pipeline system in cloud which has it’s on APIs deployed.
As we are investigating we found that the integration can be done using plugins or webhooks.
I need to know is there any other way we can consume any external APIs from Mautic other than this plug-In and webhooks method ?

Expecting your guidelines for my situation.

Thank You & Kind Regards,
Ithrees

Hi EJL,

Thank you for your reply.
If you have shared the URL documentation on available APIs which are to be used to connect Mautic from other applications, yes I got this.

But my requirement is to connect other sources from Mautic, Something like writing scripts in Mautic so I can consume external APIs of other services.

Thank You

ithress it depends on how you want to trigger these API calls, since you said script I would go by creating a custom command and then you can call php bin/console your:custom:command and at you command class you have access to all Mautic’s database and code

To create a custom command you need to create a Command/YourCommand.php file with something like

<?php

namespace MauticPlugin\YourBundle\Command;

use Mautic\CoreBundle\Command\ModeratedCommand;

/**
 * CLI command to process the e-mail queue.
 */
class YourCommandCommand extends ModeratedCommand
{
    protected function configure()
    {
        $this
            ->setName('your:custom:command');
        parent::configure();
    }

    public function __construct(/* inject dependences here and configure them at config.php*/)
    {
        parent::__construct();
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        // Your code here
        return 0;
    }
}

And register your command at config.php

    ...
    'services'    => [
        'command' => [
            'mautic.yourbundle.command.yourcommand' => [
                'class' => 'MauticPlugin\YourBundle\Command\YourCommand',
                'arguments' => [
                    // Arguments to be injected on YourCommand contructor
                ],
            ]
        ],
...