-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# This file specifies files that are *not* uploaded to Google Cloud Platform | ||
# using gcloud. It follows the same syntax as .gitignore, with the addition of | ||
# "#!include" directives (which insert the entries of the given .gitignore-style | ||
# file at that point). | ||
# | ||
# For more information, run: | ||
# $ gcloud topic gcloudignore | ||
# | ||
.gcloudignore | ||
# If you would like to upload your .git directory, .gitignore file or files | ||
# from your .gitignore file, remove the corresponding line | ||
# below: | ||
.git | ||
.gitignore | ||
|
||
# PHP Composer dependencies: | ||
/vendor/ | ||
|
||
# PHPStorm | ||
/.idea/ | ||
phpunit.xml.dist | ||
|
||
# Project files | ||
README.md | ||
/tests/ | ||
config.sample.php |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
vendor | ||
.phpunit.result.cache | ||
testdata.txt | ||
config.php | ||
token_config.php |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
`fs-mautic-hooks` is a webhook receiver for [Freemius](https://freemius.com/) that will update [Mautic](https://www.mautic.org/) contacts on specified webhook events. | ||
|
||
This is intended to be used with the [fs-mautic-sync](https://github.com/koen12344/fs-mautic-sync) initial sync script to set up the custom fields in Mautic and do an initial sync of the plugin users. | ||
|
||
This script is formatted as a Google App Engine app but could be adapted to work on different serverless platforms (or just a good ole lamp server). Feel free to fork. | ||
|
||
## Features | ||
* Uses secure Mautic oAuth2 authentication | ||
* Creates or updates Mautic contacts and companies when: | ||
* A new plugin user is created | ||
* The plugin is installed on a new site | ||
* The plugin is deactivated/uninstalled | ||
* The plugin plan is changed | ||
* The user opts in/out of the beta program | ||
* The user opts in/out of marketing emails | ||
* The user is accepted as an affiliate | ||
* The PHP, WordPress or plugin version are updated | ||
|
||
## Requirements | ||
* [gcloud cli](https://cloud.google.com/sdk/docs/install) must be installed in PATH | ||
* App engine app [must be configured](https://cloud.google.com/sdk/gcloud/reference/app/create) in your cloud project | ||
|
||
## Installation & usage | ||
1. Clone the repository | ||
2. Create a new `config.php` file in the root directory based on `config.sample.php` | ||
3. Modify the `app.yaml` to suit your needs | ||
4. Run `gcloud app deploy` to deploy the app to Google App Engine | ||
5. Navigate to `https://path-to-your-app-engine-app.appspot.com/authorize` to initialize the oAuth flow | ||
6. Add a new webhook in Freemius, pointing to `https://path-to-your-app-engine-app.appspot.com/?token=the-token-you-defined-in-config.php` | ||
|
||
## Troubleshooting | ||
* Try clearing the Mautic cache if the API is giving you issues |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
runtime: php74 | ||
service: freemius-hooks | ||
# | ||
handlers: | ||
- url: /.* | ||
script: auto | ||
secure: always |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
use FSWebhooks\TokenStorage\GoogleDataStore; | ||
|
||
session_start(); | ||
|
||
$settings = require('config.php'); | ||
|
||
require_once "vendor/autoload.php"; | ||
|
||
$token_storage = new GoogleDataStore(); | ||
$mautic_auth = new \FSWebhooks\MauticAuth($token_storage, $settings['mautic']); | ||
|
||
$auth = $mautic_auth->get_auth(); | ||
if($auth->isAuthorized()){ | ||
echo 'Everybody, come out, quick! Look at the lights! - Clark Griswold'; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"autoload": { | ||
"psr-4": {"FSWebhooks\\": "src/"} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"FSWebhooks\\Tests\\": "tests/FSWebhooks/" | ||
} | ||
}, | ||
"require": { | ||
"guzzlehttp/guzzle": "^6.3", | ||
"ext-json": "*", | ||
"mautic/api-library": "^3.0", | ||
"google/cloud-datastore": "^1.13" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^8" | ||
} | ||
} |