-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mautic API: How to integrate with WordPress plugin #62
Comments
I'm not totally familiar with how other WP plugins do this, but I have seen a few which have add-on plugins and work together with the main plugin and can hook into events that the main plugin defines. So my thoughts were that the main Mautic plugin has either an extra 'API settings' page, or API settings are just integrated into the existing settings page (Since the base url is already added there). If a public key/secret pair is added to the settings, on save, it checks to see if an authentication token is already saved as an option. Once authenticated, the API is opened up to other plugins through actions/hooks (Not sure how it works). I would imagine a hook for each endpoint of the API. For example, the segments: https://developer.mautic.org/#segments has the actions
So another plugin could then hook into the segments endpoint and pass a method and some parameters like I'm no WP master but could help with the connection part. |
Hello, So what's the goal of this integration ? Adding new contacts directly using API ? Retrieve the list of existing contacts ? Displaying some graphs in WP admin ? I've added a to do list in the description to track each point to be adressed. |
It could be anything that is allowed through the api. For example, I just started a plugin which works with memberpress. Another plugin might want to add a user directly to a campaign It could be anything, but having one main connection in the main plugin would make it easier/faster to develop new integrations as the dev wouldn't need to go through the authentication process, just hook into the methods provided by the main plugin. It would also make plugins less likely to break if there were any changes to the api library as it would only need to be updated in the main plugin. |
I think I was probably over thinking this. Since hooks and actions and whatnot happen when other code runs, my previous comments probably don't make sense. The main plugin would only need to provide the authentication part to get the API connected to the site. Once connected, we can set an option to let other plugins know that the connection is available. Then other plugins could use the class with something like:
Is there a better 'Wordpress' way to do something like this? |
Hello @robwent, I think that we can create a hook in the Mautic plugin which will be executed when the API is correctly configured. The this hook will give access to an "API" object and everything necessary to interact with the API (inspired by Then in the custom plugin we can just add a code like : add_action('wpmautic_api_init', function(MauticApi $api) {
//Here the $api variable contains a fully functional API wrapper.
}); I think it simpler than relying on custom loading when the plugin is active or not... It's also possible to display a message in the admin to the user when the root plugin is not active using the Actually it's not possible to declare plugin dependencies within the WP ecosystem, there are different discussion around but nothing really active. However, WordPress rely on a solid HTTP library (https://github.com/rmccue/Requests) to perform API calls, this is a good starting point 😄. I've updated to global TODO list. |
That sounds perfect! Where's the TODO list? |
In the issue description : #issue-233515074 |
@shulard do you have any due date to add Mautic API? I want to add Facebook Social Login to plugin (https://developers.facebook.com/docs/php/howto/example_facebook_login) , but would be nice use Mautic API to create user. My idea is create a shortcode [mautic_facebook_login] to display Facebook Login Button and after successful login add lead to Mautic. |
Hello @luizeof, Sorry but I was really busy during the summer and can't find the time to start working on that wrapper... I hope adding this feature before the middle of september. I'll inform here when it'll be ready... |
Hello guys, Sorry about the inactivity here but I had a lot of different subjects to work on... I found that @escopecz has already created an API client for Mautic. Maybe we can embed his code and use it inside our WordPress plugin ? Have you already used it ? Any feedback ? |
Probably better to use the official library? https://github.com/mautic/api-library |
@shulard we use the official api every day and is very stable. |
I basically copied the form integrator plugin to integrate it into my own stuff. |
Hello,
As we already discussed on Slack, I create this thread to discuss and define how to implement Mautic API features inside the WordPress plugin.
This issue will be used as a request for comment around the features to be introduces.
To be tracked :
wpmautic_api_init
hook to easily plug custom code which rely on APIWant to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: