Created
September 15, 2018 13:13
-
-
Save davidchc/13f665e655e5b7d49815e257761d27f9 to your computer and use it in GitHub Desktop.
Exemplo de integração no OpenCart usando Mautic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Mautic\Auth\ApiAuth; | |
use Mautic\MauticApi; | |
class ModelNewsletterMautic extends Model { | |
private $publicKey = 'CHAVE PUBLICA'; | |
private $secretKey = 'CHAVE SECRETA'; | |
private $baseURL = 'http://mautic.seusite.com.br/api'; | |
private $apiURL = 'http://mautic.seusite.com.br/api'; | |
private $contact; | |
public function __construct($registry) { | |
parent::__construct($registry); | |
$settings = array( | |
'baseUrl' => $this->baseURL, // Base URL of the Mautic instance | |
'version' => 'OAuth2', // Version of the OAuth can be OAuth2 or OAuth1a. OAuth2 is the default value. | |
'clientKey' => $this->publicKey, // Client/Consumer key from Mautic | |
'clientSecret' => $this->secretKey, // Client/Consumer secret key from Mautic | |
'callback' => 'http://seusite.com.br' , // Redirect URI/Callback URI for this script | |
); | |
$settings = array( | |
'userName' => 'USUARIO CRIADO NO MAUTIC', | |
'password' => 'SENHA', | |
); | |
$initAuth = new ApiAuth(); | |
$auth = $initAuth->newAuth($settings, 'BasicAuth'); | |
$api = new MauticApi(); | |
$this->contacts = $api->newApi('contacts', $auth, $this->apiURL); | |
} | |
public function register($customer) { | |
$data = array( | |
'firstname' => $customer['firstname'], | |
'lastname' => $customer['lastname'], | |
'email' => $customer['email'], | |
'ipAddress' => $_SERVER['REMOTE_ADDR'], | |
); | |
return $this->contacts->create($data); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment