-
Notifications
You must be signed in to change notification settings - Fork 0
/
acHelper.php
88 lines (67 loc) · 1.38 KB
/
acHelper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
require_once("../../class2.php");
require_once("vendor/autoload.php");
use ActiveCampaign;
/**
* Active Campaign Helper Class for e107
*/
class acHelper
{
/**
* @return \ActiveCampaign
* @throws RequestException
*/
private static function connect()
{
static $ac;
if(!empty($ac))
{
return $ac;
}
$acPref = e107::pref('activecampaign');
$ac = new ActiveCampaign($acPref['api_url'], $acPref['api_key']);
return $ac;
}
/**
* @return bool
* @throws RequestException
*/
public static function test()
{
$ac = self::connect();
return (bool) $ac->credentials_test();
}
/**
* @param $save
* @return mixed
*/
public static function addContact($save)
{
$tp = e107::getParser();
$ac = self::connect();
if(!empty($save['first_name']))
{
$save['first_name'] = $tp->filter($save['first_name']);
}
if(!empty($save['last_name']))
{
$save['last_name'] = $tp->filter($save['last_name']);
}
$save['email'] = filter_var($save['email'],FILTER_SANITIZE_EMAIL);
/** @var $response */
$response = $ac->api("contact/sync", $save);
if(getperms('0') && deftrue('e_DEBUG'))
{
echo "Debug (visible only to you): ";
$ac->dbg($response);
}
return $response;
}
public static function getTracking()
{
$ac = self::connect();
/** @var $response */
$response = $ac->api('tracking/site_status');
//var_dump($response);
}
}