Version Notes
You must have an account with constant contact.
and you need to enter your constant contact api key in configuration section.
Download this release
Release Info
| Developer | Magento Core Team |
| Extension | Constant_Contact |
| Version | 1.0 |
| Comparing to | |
| See all releases | |
Version 1.0
- app/code/local/Rahil/ConstantContact/Helper/Data.php +6 -0
- app/code/local/Rahil/ConstantContact/Model/Constantcontact.php +10 -0
- app/code/local/Rahil/ConstantContact/Model/List.php +39 -0
- app/code/local/Rahil/ConstantContact/api/ctctWrapper.php +3260 -0
- app/code/local/Rahil/ConstantContact/controllers/SubscriberController.php +84 -0
- app/code/local/Rahil/ConstantContact/etc/config.xml +62 -0
- app/code/local/Rahil/ConstantContact/etc/system.xml +75 -0
- app/etc/modules/Rahil_Constantcontact.xml +9 -0
- package.xml +21 -0
app/code/local/Rahil/ConstantContact/Helper/Data.php
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Rahil_Constantcontact_Helper_Data extends Mage_Core_Helper_Abstract
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
}
|
app/code/local/Rahil/ConstantContact/Model/Constantcontact.php
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Rahil_Constantcontact_Model_Constantcontact extends Mage_Core_Model_Abstract
|
| 4 |
+
{
|
| 5 |
+
public function _construct()
|
| 6 |
+
{
|
| 7 |
+
parent::_construct();
|
| 8 |
+
$this->_init('constantcontact/constantcontact');
|
| 9 |
+
}
|
| 10 |
+
}
|
app/code/local/Rahil/ConstantContact/Model/List.php
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Rahil_Constantcontact_Model_List extends Mage_Core_Model_Abstract {
|
| 3 |
+
|
| 4 |
+
public function _construct()
|
| 5 |
+
{
|
| 6 |
+
parent::_construct();
|
| 7 |
+
$this->_init('constantcontact/list');
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
public function toOptionArray()
|
| 11 |
+
{
|
| 12 |
+
|
| 13 |
+
$path = Mage::getBaseDir().'/app/code/local/Rahil/ConstantContact/api';
|
| 14 |
+
require_once($path."/ctctWrapper.php");
|
| 15 |
+
$listObj = new ListsCollection();
|
| 16 |
+
$lists = $listObj->getLists();
|
| 17 |
+
|
| 18 |
+
foreach($lists[0] as $li){
|
| 19 |
+
if($li->getOptInDefault()){
|
| 20 |
+
$label = $li->getName();
|
| 21 |
+
$value = $li->getId();
|
| 22 |
+
//$data['label'][] = (array)$label[0];
|
| 23 |
+
//$data['value'][] = (array)$value[0];
|
| 24 |
+
$data[] = array('label'=>(array)$label[0],'value'=>(array)$value[0]);
|
| 25 |
+
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
if(!empty($data)){
|
| 30 |
+
foreach($data as $d){
|
| 31 |
+
$array[] = array('label'=>$d['label'][0],'value'=>$d['value'][0]);
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
return $array;
|
| 35 |
+
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
}
|
| 39 |
+
}
|
app/code/local/Rahil/ConstantContact/api/ctctWrapper.php
ADDED
|
@@ -0,0 +1,3260 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* ctctWrapper.php
|
| 4 |
+
*
|
| 5 |
+
* Constant Contact PHP Wrapper, includes access to:
|
| 6 |
+
* 1. Contacts Collection - add, delete, update, and get contacts
|
| 7 |
+
* 2. Campaign Collection - add, delete, update, and get campaigns
|
| 8 |
+
* 3. List Collection - add, delete, update, and get lists
|
| 9 |
+
* 4. Event Collection - get events and registrants
|
| 10 |
+
* 5. Activities Collection - add, and get activities
|
| 11 |
+
* 6. Library Collection - add and get images and folders
|
| 12 |
+
*
|
| 13 |
+
* @name ctctWrapper.php
|
| 14 |
+
* @author Constant Contact API Support Team <webservices@constantcontact.com>
|
| 15 |
+
* @version 1.0
|
| 16 |
+
* @link http://developer.constantcontact.com
|
| 17 |
+
* @package ctctWrapper
|
| 18 |
+
*
|
| 19 |
+
*/
|
| 20 |
+
/**
|
| 21 |
+
* Utility Class for all HTTP calls
|
| 22 |
+
*
|
| 23 |
+
* This class is used for all the HTTP calls made: GET, PUT, POST, and DELETE
|
| 24 |
+
* Also used to make Bulk URL encoded calls and Multi Part Form calls
|
| 25 |
+
*
|
| 26 |
+
*/
|
| 27 |
+
class Utility
|
| 28 |
+
{
|
| 29 |
+
/**
|
| 30 |
+
* Public Function __construct of Utility Object
|
| 31 |
+
*
|
| 32 |
+
* Sets variables for username, password, and API key, as well as
|
| 33 |
+
* constructs the login request string: APIKey%Username:Password
|
| 34 |
+
*
|
| 35 |
+
* Also sets ActionBy settings:
|
| 36 |
+
* - ACTION_BY_CUSTOMER will add contacts as if they were being added by Site Owner.
|
| 37 |
+
* - ACTION_BY_CONTACT will add contacts as if they were added by themselves
|
| 38 |
+
*
|
| 39 |
+
*/
|
| 40 |
+
public function __construct()
|
| 41 |
+
{
|
| 42 |
+
|
| 43 |
+
$config = Mage::getStoreConfig('constantcontact');
|
| 44 |
+
|
| 45 |
+
$this->setActionBy('ACTION_BY_CUSTOMER');
|
| 46 |
+
$this->setApiKey($config['settings']['constant_api_key']);
|
| 47 |
+
$this->setApiPath('https://api.constantcontact.com');
|
| 48 |
+
$this->setLogin($config['settings']['constant_username']);
|
| 49 |
+
$this->setPassword($config['settings']['constant_password']);
|
| 50 |
+
$this->setRequestLogin($this->getApiKey() . "%" . $this->getLogin() . ":" . $this->getPassword());
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
private $actionBy;
|
| 56 |
+
private $apiKey;
|
| 57 |
+
private $apiPath;
|
| 58 |
+
private $login;
|
| 59 |
+
private $password;
|
| 60 |
+
private $requestLogin;
|
| 61 |
+
|
| 62 |
+
//Getters and Setters for the Utility class
|
| 63 |
+
public function setActionBy($value) { $this->actionBy = $value; }
|
| 64 |
+
public function getActionBy() { return $this->actionBy; }
|
| 65 |
+
|
| 66 |
+
public function setApiKey($value) { $this->apiKey = $value; }
|
| 67 |
+
public function getApiKey() { return $this->apiKey; }
|
| 68 |
+
|
| 69 |
+
public function setApiPath($value) { $this->apiPath = $value; }
|
| 70 |
+
public function getApiPath() { return $this->apiPath; }
|
| 71 |
+
|
| 72 |
+
public function setLogin($value) { $this->login = $value; }
|
| 73 |
+
public function getLogin() { return $this->login; }
|
| 74 |
+
|
| 75 |
+
public function setPassword($value) { $this->password = $value; }
|
| 76 |
+
public function getPassword() { return $this->password; }
|
| 77 |
+
|
| 78 |
+
public function setRequestLogin($value) { $this->requestLogin = $value; }
|
| 79 |
+
public function getRequestLogin() { return $this->requestLogin; }
|
| 80 |
+
|
| 81 |
+
/**
|
| 82 |
+
* Public function httpGet sends a GET request to the API server
|
| 83 |
+
*
|
| 84 |
+
* @param string $request - valid constant contact URI
|
| 85 |
+
* @return string $getRequest - returns an array from httpRequest with the API error and success messaging and codes
|
| 86 |
+
*/
|
| 87 |
+
public function httpGet($request)
|
| 88 |
+
{
|
| 89 |
+
$getRequest = $this->httpRequest('receive', 'GET', $request, '');
|
| 90 |
+
return $getRequest;
|
| 91 |
+
}
|
| 92 |
+
/**
|
| 93 |
+
* Public function httpPut sends a PUT request to the API server
|
| 94 |
+
*
|
| 95 |
+
* @param string $request - valid constant contact URI
|
| 96 |
+
* @param string $paramter - data passed to the URI
|
| 97 |
+
* @return string $getRequest - returns an array from httpRequest with the API error and success messaging and codes
|
| 98 |
+
*/
|
| 99 |
+
public function httpPut($request, $parameter)
|
| 100 |
+
{
|
| 101 |
+
$putRequest = $this->httpRequest('send', 'PUT', $request, $parameter);
|
| 102 |
+
return $putRequest;
|
| 103 |
+
}
|
| 104 |
+
/**
|
| 105 |
+
* Public function httpPost sends a POST request to the API server
|
| 106 |
+
*
|
| 107 |
+
* @param string $request - valid constant contact URI
|
| 108 |
+
* @param string $paramter - data passed to the URI
|
| 109 |
+
* @return string $getRequest - returns an array from httpRequest with the API error and success messaging and codes
|
| 110 |
+
*/
|
| 111 |
+
public function httpPost($request, $parameter)
|
| 112 |
+
{
|
| 113 |
+
$postRequest = $this->httpRequest('send', 'POST', $request, $parameter);
|
| 114 |
+
return $postRequest;
|
| 115 |
+
}
|
| 116 |
+
/**
|
| 117 |
+
* Public function httpDelete sends a DELETE request to the API server
|
| 118 |
+
*
|
| 119 |
+
* @param string $request - valid constant contact URI
|
| 120 |
+
* @return string $getRequest - returns an array from httpRequest with the API error and success messaging and codes
|
| 121 |
+
*/
|
| 122 |
+
public function httpDelete($request)
|
| 123 |
+
{
|
| 124 |
+
$deleteRequest = $this->httpRequest('receive', 'DELETE', $request, '');
|
| 125 |
+
return $deleteRequest;
|
| 126 |
+
}
|
| 127 |
+
/**
|
| 128 |
+
* Public function urlEncodedPost sends a POST request to the API server for URL encoded requests
|
| 129 |
+
*
|
| 130 |
+
* @param string $request - valid constant contact URI
|
| 131 |
+
* @param string $paramter - data passed to the URI
|
| 132 |
+
* @return string $getRequest - returns an array from httpRequest with the API error and success messaging and codes
|
| 133 |
+
*/
|
| 134 |
+
public function urlEncodedPost($request, $parameter)
|
| 135 |
+
{
|
| 136 |
+
$encodeRequest = $this->httpRequest('urlEncode', 'POST', $request, $parameter);
|
| 137 |
+
return $encodeRequest;
|
| 138 |
+
}
|
| 139 |
+
/**
|
| 140 |
+
* Public function multiPartPost sends a POST request to the API server for multipart/form data requests
|
| 141 |
+
*
|
| 142 |
+
* @param string $request - valid constant contact URI
|
| 143 |
+
* @param string $paramter - data passed to the URI
|
| 144 |
+
* @return string $getRequest - returns an array from httpRequest with the API error and success messaging and codes
|
| 145 |
+
*/
|
| 146 |
+
public function multiPartPost($request, $parameter)
|
| 147 |
+
{
|
| 148 |
+
$multiPartRequest = $this->httpRequest('multiPart', 'POST', $request, $parameter);
|
| 149 |
+
return $multiPartRequest;
|
| 150 |
+
}
|
| 151 |
+
/**
|
| 152 |
+
* Private function httpRequest sends requests to the API server
|
| 153 |
+
*
|
| 154 |
+
* @param string $info - Type of request, multipart, urlEncode, receive, or send
|
| 155 |
+
* @param string $type - Server call, POST, GET, PUT, DELETE
|
| 156 |
+
* @param string $request - valid constant contact URI
|
| 157 |
+
* @param string $parameter - data passed to the URII
|
| 158 |
+
* @return string $return - returns an array from httpRequest with the API error and success messaging and codes
|
| 159 |
+
*/
|
| 160 |
+
private function httpRequest($info, $type, $request, $parameter)
|
| 161 |
+
{
|
| 162 |
+
$ch = curl_init();
|
| 163 |
+
curl_setopt($ch, CURLOPT_URL, $request);
|
| 164 |
+
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
|
| 165 |
+
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
| 166 |
+
curl_setopt($ch, CURLOPT_USERPWD, $this->getRequestLogin());
|
| 167 |
+
curl_setopt($ch, CURLOPT_HEADER, 0);
|
| 168 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
| 169 |
+
|
| 170 |
+
if ($info == 'urlEncode')
|
| 171 |
+
{
|
| 172 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type:application/x-www-form-urlencoded", 'Content-Length: ' . strlen($parameter)));
|
| 173 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameter);
|
| 174 |
+
}
|
| 175 |
+
else if ($info == 'multiPart')
|
| 176 |
+
{
|
| 177 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type:multipart/form-data"));
|
| 178 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameter);
|
| 179 |
+
}
|
| 180 |
+
else
|
| 181 |
+
{
|
| 182 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type:application/atom+xml", "accept:application/atom+xml", 'Content-Length: ' . strlen($parameter)));
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
|
| 186 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
| 187 |
+
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
|
| 188 |
+
|
| 189 |
+
if ($info == 'send')
|
| 190 |
+
{
|
| 191 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameter);
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
$return['xml'] = curl_exec($ch);
|
| 195 |
+
$return['info'] = curl_getinfo($ch);
|
| 196 |
+
$return['error'] = curl_error($ch);
|
| 197 |
+
|
| 198 |
+
return $return;
|
| 199 |
+
}
|
| 200 |
+
}
|
| 201 |
+
/**
|
| 202 |
+
* Activities Collection Class for Activitiy API calls
|
| 203 |
+
*
|
| 204 |
+
* Includes functions for listing all activities within the account, specific activity details,
|
| 205 |
+
* creating a bulk import with Multipart/form data and bulk url encoded calls, also bulk export
|
| 206 |
+
*
|
| 207 |
+
*/
|
| 208 |
+
class ActivitiesCollection
|
| 209 |
+
{
|
| 210 |
+
/**
|
| 211 |
+
* Public function that Gets a list of first 50 Activities in the account
|
| 212 |
+
*
|
| 213 |
+
* @return array $allActivities - array of two arrays, array 1 is activity objects, array 2 is link for next 50 activities
|
| 214 |
+
*/
|
| 215 |
+
public function listActivities()
|
| 216 |
+
{
|
| 217 |
+
$utility = new Utility();
|
| 218 |
+
$return = $utility->httpGet($utility->getApiPath() . '/ws/customers/'. $utility->getLogin() .'/activities');
|
| 219 |
+
$allActivities = array();
|
| 220 |
+
|
| 221 |
+
$activityList = array();
|
| 222 |
+
$pages = array();
|
| 223 |
+
|
| 224 |
+
$parsedReturn = simplexml_load_string($return['xml']);
|
| 225 |
+
|
| 226 |
+
foreach ($parsedReturn->entry as $item)
|
| 227 |
+
{
|
| 228 |
+
$activity = new Activity();
|
| 229 |
+
$activity->setLink($item->link['href']);
|
| 230 |
+
$activity->setId($item->id);
|
| 231 |
+
$activity->setActivityTitle($item->content->title);
|
| 232 |
+
$activity->setType($item->content->Activity->Type);
|
| 233 |
+
$activity->setStatus($item->content->Activity->Status);
|
| 234 |
+
$activity->setTransactionCount($item->content->Activity->TransactionCount);
|
| 235 |
+
$activity->setErrorCount($item->content->Activity->Errors);
|
| 236 |
+
$activity->setRunStartTime($item->content->Activity->RunStartTime);
|
| 237 |
+
$activity->setRunFinishTime($item->content->Activity->RunFinishTime);
|
| 238 |
+
$activity->setInsertTime($item->content->Activity->InsertTime);
|
| 239 |
+
|
| 240 |
+
$activityList[] = $activity;
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
if ($parsedReturn->link[2])
|
| 244 |
+
{
|
| 245 |
+
$pages[] = $parsedReturn->link[2]->Attributes()->href;
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
$allActivities = array($activityList, $pages);
|
| 249 |
+
|
| 250 |
+
return $allActivities;
|
| 251 |
+
}
|
| 252 |
+
/**
|
| 253 |
+
* Public function that gets full details of a specific activity, from an activity object.
|
| 254 |
+
*
|
| 255 |
+
* @param object $activity - a valid activity object with valid activity link
|
| 256 |
+
* @return object $activity with full details of the passed activity object
|
| 257 |
+
*/
|
| 258 |
+
public function listActivityDetails($activity)
|
| 259 |
+
{
|
| 260 |
+
$utility = new Utility();
|
| 261 |
+
$call = $utility->getApiPath() . $activity->getLink();
|
| 262 |
+
$return = $utility->httpGet($call);
|
| 263 |
+
$activity = $this->createActivityStruct($return['xml']);
|
| 264 |
+
if (!$return)
|
| 265 |
+
{
|
| 266 |
+
return false;
|
| 267 |
+
}
|
| 268 |
+
else
|
| 269 |
+
{
|
| 270 |
+
return $activity;
|
| 271 |
+
}
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
/**
|
| 275 |
+
* Public function POSTs a URL encoded string to the activities collection, for bulk importing and exporting.
|
| 276 |
+
*
|
| 277 |
+
* @param string $urlEncodedPost - URL encoded string that follows this format:
|
| 278 |
+
* - activityType=SV_ADD&data=Email+Address%2CFirst+Name%2CLast+Name%0Awstest3%40example.com%2C+Fred%2C+Test%0Awstest4%40example.com%2C+Joan%2C+Test%0Awstest5%40example.com%2C+Ann%2C+Test&lists=http%3A%2F%2Fapi.constantcontact.com%2Fws%2Fcustomers%2Fjoesflowers%2Flists%2F2&lists=http%3A%2F%2Fapi.constantcontact.com%2Fws%2Fcustomers%2Fjoesflowers%2Flists%2F5
|
| 279 |
+
* @return string - Success or Fail code from the API server
|
| 280 |
+
*/
|
| 281 |
+
public function bulkUrlEncoded($urlEncodedPost)
|
| 282 |
+
{
|
| 283 |
+
$utility = new Utility();
|
| 284 |
+
$call = $utility->getApiPath() . '/ws/customers/' . $utility->getLogin() .'/activities';
|
| 285 |
+
$return = $utility->urlEncodedPost($call, $urlEncodedPost);
|
| 286 |
+
$code = $return['info']['http_code'];
|
| 287 |
+
return $code;
|
| 288 |
+
}
|
| 289 |
+
//
|
| 290 |
+
/**
|
| 291 |
+
* Public function that sends a POST request that creates an Export Contact Activity, returns exported activity
|
| 292 |
+
*
|
| 293 |
+
* @param string $filetype - either CSV or TXT file to upload
|
| 294 |
+
* @param object $list - valid list object
|
| 295 |
+
* @param string $exportOptDate - true to include the Add/Remove Date in the export file, false to not include it
|
| 296 |
+
* @param string $exportOptSource - true to include the Added/Removed By (source of add or remove) in the export file, false to not include it
|
| 297 |
+
* @param string exportListName - true to include the List Name in the export file, false to not include it
|
| 298 |
+
* @param string sortBy - EMAIL_ADDRESS to sort the list by email address in ascending order. DATE_DESC will sort the contacts by the Date in descending order
|
| 299 |
+
* @return object $activity with full details of the created activity object
|
| 300 |
+
*/
|
| 301 |
+
public function exportContacts($filetype, $list, $exportOptDate, $exportOptSource, $exportListName, $sortBy, $columns = array())
|
| 302 |
+
{
|
| 303 |
+
$utility = new Utility();
|
| 304 |
+
$call = $utility->getApiPath() . '/ws/customers/' . $utility->getLogin() .'/activities';
|
| 305 |
+
|
| 306 |
+
foreach ($columns as $item)
|
| 307 |
+
{
|
| 308 |
+
$allColumns .= '&columns=' . urlencode($item);
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
$urlEncodedPost = "activityType=EXPORT_CONTACTS&fileType=" . $filetype . "&exportOptDate=" . $exportOptDate . "&exportOptSource=" . $exportOptSource . "&exportListName=" . $exportListName . "&sortBy=" . $sortBy . $allColumns . "&listId=" . urlencode($list->getId());
|
| 312 |
+
$activityXml = $utility->urlEncodedPost($call, $urlEncodedPost);
|
| 313 |
+
$activity = $this->createActivityStruct($activityXml);
|
| 314 |
+
|
| 315 |
+
return $activity;
|
| 316 |
+
}
|
| 317 |
+
/**
|
| 318 |
+
* Public function that passes @fileArray to the activities collection
|
| 319 |
+
* as a mutlipart/form data request
|
| 320 |
+
*
|
| 321 |
+
* @param array $fileArray - array of dataFile, activityType and lists
|
| 322 |
+
* @return string - Success or Fail code from the API server
|
| 323 |
+
*/
|
| 324 |
+
public function multiPart($fileArray)
|
| 325 |
+
{
|
| 326 |
+
$utility = new Utility();
|
| 327 |
+
$call = $utility->getApiPath() . '/ws/customers/' . $utility->getLogin() .'/activities';
|
| 328 |
+
$return = $utility->multiPartPost($call, $fileArray);
|
| 329 |
+
$code = $return['info']['http_code'];
|
| 330 |
+
return $code;
|
| 331 |
+
}
|
| 332 |
+
/**
|
| 333 |
+
* Private function that creates the structure for an Activity Object
|
| 334 |
+
*
|
| 335 |
+
* @param string $activityXml - the returned XML from an activity call as a string
|
| 336 |
+
* @return object $activityObj - valid activity object
|
| 337 |
+
*/
|
| 338 |
+
private function createActivityStruct($activityXml)
|
| 339 |
+
{
|
| 340 |
+
$activity = array();
|
| 341 |
+
$parsedReturn = simplexml_load_string($activityXml);
|
| 342 |
+
$activity['link'] = ($parsedReturn->link->Attributes()->href);
|
| 343 |
+
$activity['id'] = ($parsedReturn->id);
|
| 344 |
+
$activity['activity_title'] = ($parsedReturn->title);
|
| 345 |
+
$activity['updated'] = ($parsedReturn->updated);
|
| 346 |
+
$activity['type'] = ($parsedReturn->content->Activity->Type);
|
| 347 |
+
$activity['status'] = ($parsedReturn->content->Activity->Status);
|
| 348 |
+
$activity['transaction_count'] = ($parsedReturn->content->Activity->TransactionCount);
|
| 349 |
+
$activity['run_start_time'] = ($parsedReturn->content->Activity->RunStartTime);
|
| 350 |
+
$activity['run_finish_time'] = ($parsedReturn->content->Activity->RunFinishTime);
|
| 351 |
+
$activity['file_name'] = ($parsedReturn->content->Activity->FileName);
|
| 352 |
+
|
| 353 |
+
if ($parsedReturn->content->Contact->ContactLists->ContactList)
|
| 354 |
+
{
|
| 355 |
+
foreach ($parsedReturn->content->Activity->Errors->Error as $item)
|
| 356 |
+
{
|
| 357 |
+
$activity['errors'][$item]['LineNumber'] = (trim((string) $item->LineNumber));
|
| 358 |
+
$activity['errors'][$item]['EmailAddress'] = (trim((string) $item->EmailAddress));
|
| 359 |
+
$activity['errors'][$item]['Message'] = (trim((string) $item->Message));
|
| 360 |
+
}
|
| 361 |
+
}
|
| 362 |
+
|
| 363 |
+
$activityObj = new Activity($activity);
|
| 364 |
+
return $activityObj;
|
| 365 |
+
}
|
| 366 |
+
}
|
| 367 |
+
/**
|
| 368 |
+
* Activity class defines an activity object
|
| 369 |
+
*
|
| 370 |
+
* Defines an activity object, includes all activity variables as well as the
|
| 371 |
+
* getters and setters for variables
|
| 372 |
+
*
|
| 373 |
+
*/
|
| 374 |
+
class Activity
|
| 375 |
+
{
|
| 376 |
+
/**
|
| 377 |
+
* Construct function for the Activity Class
|
| 378 |
+
*
|
| 379 |
+
* @param array $params - an array of variables that set up an activity object
|
| 380 |
+
* @return object - activity object with passed variables set to the object
|
| 381 |
+
*/
|
| 382 |
+
public function __construct($params = array())
|
| 383 |
+
{
|
| 384 |
+
$this->setLink($params['link']);
|
| 385 |
+
$this->setId($params['id']);
|
| 386 |
+
$this->setUpdated($params['updated']);
|
| 387 |
+
$this->setType($params['type']);
|
| 388 |
+
$this->setActivityTitle($params['activity_title']);
|
| 389 |
+
$this->setStatus($params['status']);
|
| 390 |
+
$this->setTransactionCount($params['transaction_count']);
|
| 391 |
+
$this->setRunStartTime($params['run_start_time']);
|
| 392 |
+
$this->setRunFinishTime($params['run_finish_time']);
|
| 393 |
+
$this->setFileName($params['file_name']);
|
| 394 |
+
$this->setErrorCount($params['error_count']);
|
| 395 |
+
if ($params['errors'])
|
| 396 |
+
{
|
| 397 |
+
foreach ($params['errors'] as $tmp)
|
| 398 |
+
{
|
| 399 |
+
$this->setErrors($tmp);
|
| 400 |
+
}
|
| 401 |
+
}
|
| 402 |
+
|
| 403 |
+
return $this;
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
private $link;
|
| 407 |
+
private $id;
|
| 408 |
+
private $updated;
|
| 409 |
+
private $type;
|
| 410 |
+
private $activityTitle;
|
| 411 |
+
private $status;
|
| 412 |
+
private $transactionCount;
|
| 413 |
+
private $runStartTime;
|
| 414 |
+
private $runFinishTime;
|
| 415 |
+
private $insertTime;
|
| 416 |
+
private $fileName;
|
| 417 |
+
private $errorCount;
|
| 418 |
+
private $errors = array();
|
| 419 |
+
|
| 420 |
+
public function setLink( $value ) { $this->link = $value; }
|
| 421 |
+
public function getLink() { return $this->link; }
|
| 422 |
+
|
| 423 |
+
public function setId( $value ) { $this->id = $value; }
|
| 424 |
+
public function getId() { return $this->id; }
|
| 425 |
+
|
| 426 |
+
public function setUpdated( $value ) { $this->updated = $value; }
|
| 427 |
+
public function getUpdated() { return $this->updated; }
|
| 428 |
+
|
| 429 |
+
public function setType( $value ) { $this->type = $value; }
|
| 430 |
+
public function getType() { return $this->type; }
|
| 431 |
+
|
| 432 |
+
public function setActivityTitle( $value ) { $this->activityTitle = $value; }
|
| 433 |
+
public function getActivityTitle() { return $this->activityTitle; }
|
| 434 |
+
|
| 435 |
+
public function setStatus( $value ) { $this->status = $value; }
|
| 436 |
+
public function getStatus() { return $this->status; }
|
| 437 |
+
|
| 438 |
+
public function setTransactionCount( $value ) { $this->transactionCount = $value; }
|
| 439 |
+
public function getTransactionCount() { return $this->transactionCount; }
|
| 440 |
+
|
| 441 |
+
public function setRunStartTime( $value ) { $this->runStartTime = $value; }
|
| 442 |
+
public function getRunStartTime() { return $this->runStartTime; }
|
| 443 |
+
|
| 444 |
+
public function setRunFinishTime( $value ) { $this->runFinishTime = $value; }
|
| 445 |
+
public function getRunFinishTime() { return $this->runFinishTime; }
|
| 446 |
+
|
| 447 |
+
public function setInsertTime( $value ) { $this->insertTime = $value; }
|
| 448 |
+
public function getInsertTime() { return $this->insertTime; }
|
| 449 |
+
|
| 450 |
+
public function setFileName( $value ) { $this->fileName = $value; }
|
| 451 |
+
public function getFileName() { return $this->fileName; }
|
| 452 |
+
|
| 453 |
+
public function setErrorCount( $value ) { $this->errorCount = $value; }
|
| 454 |
+
public function getErrorCount() { return $this->errorCount; }
|
| 455 |
+
|
| 456 |
+
public function setErrors( $value ) { $this->errors[] = $value; }
|
| 457 |
+
public function getErrors() { return $this->errors; }
|
| 458 |
+
}
|
| 459 |
+
/**
|
| 460 |
+
* Library Collection Class for calls to the library collection API
|
| 461 |
+
*
|
| 462 |
+
* Includes functions to create folders, list folders, list images and delete images and folders
|
| 463 |
+
*
|
| 464 |
+
*/
|
| 465 |
+
class LibraryCollection
|
| 466 |
+
{
|
| 467 |
+
/**
|
| 468 |
+
* Public function that gets a list of first 50 folders in the account
|
| 469 |
+
*
|
| 470 |
+
* @return array $allFolders - an array of two arrays, array 1 is folder objects, array 2 is link for next 50 folders
|
| 471 |
+
*/
|
| 472 |
+
public function listFolders()
|
| 473 |
+
{
|
| 474 |
+
$utility = new Utility();
|
| 475 |
+
$return = $utility->httpGet($utility->getApiPath() . '/ws/customers/'. $utility->getLogin() .'/library/folders');
|
| 476 |
+
$allFolders = array();
|
| 477 |
+
|
| 478 |
+
$folderList = array();
|
| 479 |
+
$pages = array();
|
| 480 |
+
|
| 481 |
+
$parsedReturn = simplexml_load_string($return['xml'], null, null, "http://www.w3.org/2005/Atom");
|
| 482 |
+
|
| 483 |
+
foreach ($parsedReturn->entry as $item)
|
| 484 |
+
{
|
| 485 |
+
$folder = new Folder();
|
| 486 |
+
$folder->setFolderLink($item->link->Attributes()->href);
|
| 487 |
+
$folder->setFolderId($item->id);
|
| 488 |
+
$folder->setFolderName($item->title);
|
| 489 |
+
$folderList[] = $folder;
|
| 490 |
+
}
|
| 491 |
+
|
| 492 |
+
if ($parsedReturn->link[2])
|
| 493 |
+
{
|
| 494 |
+
$pages[] = $parsedReturn->link[2]->Attributes()->href;
|
| 495 |
+
}
|
| 496 |
+
|
| 497 |
+
$allFolders = array($folderList, $pages);
|
| 498 |
+
|
| 499 |
+
return $allFolders;
|
| 500 |
+
}
|
| 501 |
+
/**
|
| 502 |
+
* Public function that does a POST to the Library collection, passing a folder object
|
| 503 |
+
*
|
| 504 |
+
* @param object $folder - a valid folder object with all required fields
|
| 505 |
+
* @return string $code - returns success or fail code from API server
|
| 506 |
+
*/
|
| 507 |
+
public function createFolder($folder)
|
| 508 |
+
{
|
| 509 |
+
$utility = new Utility();
|
| 510 |
+
$call = $utility->getApiPath() . '/ws/customers/'. $utility->getLogin() .'/library/folders';
|
| 511 |
+
$folderStruct = $this->createFolderXml($folder);
|
| 512 |
+
$return = $utility->httpPost($call, $folderStruct);
|
| 513 |
+
$code = $return['info']['http_code'];
|
| 514 |
+
return $code;
|
| 515 |
+
}
|
| 516 |
+
/**
|
| 517 |
+
* Public function that gets a list of first 50 images in the account
|
| 518 |
+
*
|
| 519 |
+
* @return array $allImages - an array of two arrays, array 1 is image objects, array 2 is link for next 50 images
|
| 520 |
+
*/
|
| 521 |
+
public function listImages($folder)
|
| 522 |
+
{
|
| 523 |
+
$utility = new Utility();
|
| 524 |
+
$return = $utility->httpGet($utility->getApiPath() . $folder->getFolderLink() . '/images');
|
| 525 |
+
$allImages = array();
|
| 526 |
+
$imageArray = array();
|
| 527 |
+
$imageList = array();
|
| 528 |
+
$pages = array();
|
| 529 |
+
|
| 530 |
+
$parsedReturn = simplexml_load_string($return['xml'], null, null, "http://www.w3.org/2005/Atom");
|
| 531 |
+
|
| 532 |
+
foreach ($parsedReturn->entry as $item)
|
| 533 |
+
{
|
| 534 |
+
$imageArray['image_link'] = $item->link->Attributes()->href;
|
| 535 |
+
$imageArray['file_name'] = $item->title;
|
| 536 |
+
$imageArray['last_updated'] = $item->updated;
|
| 537 |
+
$imageArray['file_type'] = $item->content->Image->FileType;
|
| 538 |
+
$image = new Image($imageArray);
|
| 539 |
+
$imageList[] = $image;
|
| 540 |
+
}
|
| 541 |
+
|
| 542 |
+
if ($parsedReturn->link[2])
|
| 543 |
+
{
|
| 544 |
+
$pages[] = $parsedReturn->link[2]->Attributes()->href;
|
| 545 |
+
}
|
| 546 |
+
|
| 547 |
+
$allImages = array($imageList, $pages);
|
| 548 |
+
|
| 549 |
+
return $allImages;
|
| 550 |
+
}
|
| 551 |
+
/**
|
| 552 |
+
* Public function that gets image details of a single image object passed to it.
|
| 553 |
+
*
|
| 554 |
+
* @param object $image - a valid image object with a valid image link
|
| 555 |
+
* @return object $image - returns image object with full details
|
| 556 |
+
*/
|
| 557 |
+
public function listImageDetails($image)
|
| 558 |
+
{
|
| 559 |
+
$utility = new Utility();
|
| 560 |
+
$call = $utility->getApiPath() . $image->getLink();
|
| 561 |
+
$return = $utility->httpGet($call);
|
| 562 |
+
$imageStruct = $this->createImageStruct($return['xml']);
|
| 563 |
+
if (!$return)
|
| 564 |
+
{
|
| 565 |
+
return false;
|
| 566 |
+
}
|
| 567 |
+
else
|
| 568 |
+
{
|
| 569 |
+
return $imageStruct;
|
| 570 |
+
}
|
| 571 |
+
}
|
| 572 |
+
/**
|
| 573 |
+
* Public function that deletes an image from the account
|
| 574 |
+
*
|
| 575 |
+
* @param object $image - a valid image object with a valid image link
|
| 576 |
+
* @return string $code - returns success or fail code from API server
|
| 577 |
+
*/
|
| 578 |
+
public function deleteImage($image)
|
| 579 |
+
{
|
| 580 |
+
$utility = new Utility();
|
| 581 |
+
$call = $utility->getApiPath() . $image->getLink();
|
| 582 |
+
$return = $utility->httpDelete($call);
|
| 583 |
+
$code = $return['info']['http_code'];
|
| 584 |
+
return $code;
|
| 585 |
+
}
|
| 586 |
+
/**
|
| 587 |
+
* Public function that removes every image from a specific folder
|
| 588 |
+
*
|
| 589 |
+
* @param object $folder - a valid folder object with a valid folder link
|
| 590 |
+
* @return string $code - returns success or fail code from API server
|
| 591 |
+
*/
|
| 592 |
+
public function clearFolder($folder)
|
| 593 |
+
{
|
| 594 |
+
$utility = new Utility();
|
| 595 |
+
$call = $utility->getApiPath() . $folder->getFolderLink() . '/images';
|
| 596 |
+
$return = $utility->httpDelete($call);
|
| 597 |
+
$code = $return['info']['http_code'];
|
| 598 |
+
return $code;
|
| 599 |
+
}
|
| 600 |
+
/**
|
| 601 |
+
* Private function that creates folder XML
|
| 602 |
+
*
|
| 603 |
+
* @param object $folder - a valid folder object with all required fields
|
| 604 |
+
* @return string $xmlReturn - valid XML of a folder
|
| 605 |
+
*/
|
| 606 |
+
private function createFolderXml($folder)
|
| 607 |
+
{
|
| 608 |
+
$utility = new Utility();
|
| 609 |
+
$xml = simplexml_load_string("<?xml version='1.0' encoding='UTF-8' standalone='yes'?><atom:entry xmlns:atom='http://www.w3.org/2005/Atom'/>");
|
| 610 |
+
$content = $xml->addChild("content");
|
| 611 |
+
$folderNode = $content->addChild("Folder", "", "");
|
| 612 |
+
$folderNode->addChild("Name", $folder->getFolderName());
|
| 613 |
+
$xmlReturn = $xml->asXML();
|
| 614 |
+
return $xmlReturn;
|
| 615 |
+
}
|
| 616 |
+
/**
|
| 617 |
+
* Private function that creates a folder object from XML
|
| 618 |
+
*
|
| 619 |
+
* @param string $folderXml - Valid folder XML
|
| 620 |
+
* @return object $folderStruct - returns a valid folder object
|
| 621 |
+
*/
|
| 622 |
+
private function createFolderStruct($folderXml)
|
| 623 |
+
{
|
| 624 |
+
$folder = array();
|
| 625 |
+
$parsedReturn = simplexml_load_string($folderXml, null, null, "http://www.w3.org/2005/Atom");
|
| 626 |
+
$folder['folderLink'] = ($parsedReturn->link);
|
| 627 |
+
$folder['folderId'] = ($parsedReturn->id);
|
| 628 |
+
$folder['folderName'] = ($parsedReturn->content->Folder->Name);
|
| 629 |
+
$folderStruct = new Folder($folder);
|
| 630 |
+
return $folderStruct;
|
| 631 |
+
}
|
| 632 |
+
/**
|
| 633 |
+
* Private function that creates an image object from XML
|
| 634 |
+
*
|
| 635 |
+
* @param string $imageXml - Valid image XML
|
| 636 |
+
* @return object $imageStruct - returns a valid image object
|
| 637 |
+
*/
|
| 638 |
+
private function createImageStruct($imageXml)
|
| 639 |
+
{
|
| 640 |
+
$image = array();
|
| 641 |
+
$parsedReturn = simplexml_load_string($imageXml);
|
| 642 |
+
$parsedArray = $parsedReturn->xpath('atom:content/Image');
|
| 643 |
+
$image['image_link'] = ("");
|
| 644 |
+
$image['file_name'] = ($parsedArray[0]->FileName);
|
| 645 |
+
$image['image_url'] = ($parsedArray[0]->ImageURL);
|
| 646 |
+
$image['image_height'] = ($parsedArray[0]->Height);
|
| 647 |
+
$image['image_width'] = ($parsedArray[0]->Width);
|
| 648 |
+
$image['description'] = ($parsedArray[0]->Description);
|
| 649 |
+
$image['MD5Hash'] = ($parsedArray[0]->MD5Hash);
|
| 650 |
+
$image['file_size'] = ($parsedArray[0]->FileSize);
|
| 651 |
+
$image['last_updated'] = ($parsedArray[0]->LastUpdated);
|
| 652 |
+
$image['file_type'] = ($parsedArray[0]->FileType);
|
| 653 |
+
|
| 654 |
+
if ($parsedArray[0]->ImageUsages)
|
| 655 |
+
{
|
| 656 |
+
foreach ($parsedArray[0]->ImageUsages->ImageUsage as $item)
|
| 657 |
+
{
|
| 658 |
+
$image['image_usage'][] = (trim((string) $item->Link->href));
|
| 659 |
+
}
|
| 660 |
+
}
|
| 661 |
+
|
| 662 |
+
$imageStruct = new Image($image);
|
| 663 |
+
return $imageStruct;
|
| 664 |
+
|
| 665 |
+
}
|
| 666 |
+
|
| 667 |
+
}
|
| 668 |
+
/**
|
| 669 |
+
* Folder class defines a folder object
|
| 670 |
+
*
|
| 671 |
+
* Defines a folder object, includes all campaign variables as well as the
|
| 672 |
+
* getters and setters for variables
|
| 673 |
+
*
|
| 674 |
+
*/
|
| 675 |
+
class Folder
|
| 676 |
+
{
|
| 677 |
+
/**
|
| 678 |
+
* Construct function for the Folder Class
|
| 679 |
+
*
|
| 680 |
+
* @param array $params - an array of variables that set up a folder object
|
| 681 |
+
* @return object folder object with passed variables set to the object
|
| 682 |
+
*/
|
| 683 |
+
public function __construct($params = array())
|
| 684 |
+
{
|
| 685 |
+
$this->setFolderLink($params['folderLink']);
|
| 686 |
+
$this->setFolderId($params['folderId']);
|
| 687 |
+
$this->setFolderName($params['folderName']);
|
| 688 |
+
|
| 689 |
+
return $this;
|
| 690 |
+
}
|
| 691 |
+
|
| 692 |
+
private $folderName;
|
| 693 |
+
private $folderId;
|
| 694 |
+
private $folderLink;
|
| 695 |
+
|
| 696 |
+
public function setFolderName( $value ) { $this->folderName = $value; }
|
| 697 |
+
public function getFolderName() { return $this->folderName; }
|
| 698 |
+
|
| 699 |
+
public function setFolderId( $value ) { $this->folderId = $value; }
|
| 700 |
+
public function getFolderId() { return $this->folderId; }
|
| 701 |
+
|
| 702 |
+
public function setFolderLink( $value ) { $this->folderLink = $value; }
|
| 703 |
+
public function getFolderLink() { return $this->folderLink; }
|
| 704 |
+
}
|
| 705 |
+
/**
|
| 706 |
+
* Image class defines an Image object
|
| 707 |
+
*
|
| 708 |
+
* Defines an Image object, includes all campaign variables as well as the
|
| 709 |
+
* getters and setters for variables
|
| 710 |
+
*
|
| 711 |
+
*/
|
| 712 |
+
class Image
|
| 713 |
+
{
|
| 714 |
+
/**
|
| 715 |
+
* Construct function for the Image Class
|
| 716 |
+
*
|
| 717 |
+
* @param array $params - an array of variables that set up an image object
|
| 718 |
+
* @return object image object with passed variables set to the object
|
| 719 |
+
*/
|
| 720 |
+
public function __construct($params = array())
|
| 721 |
+
{
|
| 722 |
+
$this->setLink($params['image_link']);
|
| 723 |
+
$this->setFileName($params['file_name']);
|
| 724 |
+
$this->setImageUrl($params['image_url']);
|
| 725 |
+
$this->setHeight($params['image_height']);
|
| 726 |
+
$this->setWidth($params['image_width']);
|
| 727 |
+
$this->setDescription($params['description']);
|
| 728 |
+
$this->setMd5Hash($params['MD5Hash']);
|
| 729 |
+
$this->setFileSize($params['file_size']);
|
| 730 |
+
$this->setUpdated($params['last_updated']);
|
| 731 |
+
$this->setFileType($params['file_type']);
|
| 732 |
+
|
| 733 |
+
if ($params['image_usage'])
|
| 734 |
+
{
|
| 735 |
+
foreach ($params['image_usage'] as $tmp)
|
| 736 |
+
{
|
| 737 |
+
$this->setImageUsage($tmp);
|
| 738 |
+
}
|
| 739 |
+
}
|
| 740 |
+
|
| 741 |
+
return $this;
|
| 742 |
+
}
|
| 743 |
+
|
| 744 |
+
private $link;
|
| 745 |
+
private $fileName;
|
| 746 |
+
private $fileType;
|
| 747 |
+
private $imageUrl;
|
| 748 |
+
private $height;
|
| 749 |
+
private $width;
|
| 750 |
+
private $description;
|
| 751 |
+
private $fileSize;
|
| 752 |
+
private $updated;
|
| 753 |
+
private $md5Hash;
|
| 754 |
+
private $imageUsage = array();
|
| 755 |
+
|
| 756 |
+
public function setLink( $value ) { $this->link = $value; }
|
| 757 |
+
public function getLink() { return $this->link; }
|
| 758 |
+
|
| 759 |
+
public function setFileName( $value ) { $this->fileName = $value; }
|
| 760 |
+
public function getFileName() { return $this->fileName; }
|
| 761 |
+
|
| 762 |
+
public function setFileType( $value ) { $this->fileType = $value; }
|
| 763 |
+
public function getFileType() { return $this->fileType; }
|
| 764 |
+
|
| 765 |
+
public function setImageUrl( $value ) { $this->imageUrl = $value; }
|
| 766 |
+
public function getImageUrl() { return $this->imageUrl; }
|
| 767 |
+
|
| 768 |
+
public function setHeight( $value ) { $this->height = $value; }
|
| 769 |
+
public function getHeight() { return $this->height; }
|
| 770 |
+
|
| 771 |
+
public function setWidth( $value ) { $this->width = $value; }
|
| 772 |
+
public function getWidth() { return $this->width; }
|
| 773 |
+
|
| 774 |
+
public function setDescription( $value ) { $this->description = $value; }
|
| 775 |
+
public function getDescription() { return $this->description; }
|
| 776 |
+
|
| 777 |
+
public function setFileSize( $value ) { $this->fileSize = $value; }
|
| 778 |
+
public function getFileSize() { return $this->fileSize; }
|
| 779 |
+
|
| 780 |
+
public function setUpdated( $value ) { $this->updated = $value; }
|
| 781 |
+
public function getUpdated() { return $this->updated; }
|
| 782 |
+
|
| 783 |
+
public function setMd5Hash( $value ) { $this->md5Hash = $value; }
|
| 784 |
+
public function getMd5Hash() { return $this->md5Hash; }
|
| 785 |
+
|
| 786 |
+
public function setImageUsage( $value ) { $this->imageUsage[] = $value; }
|
| 787 |
+
public function getImageUsage() { return $this->imageUsage; }
|
| 788 |
+
}
|
| 789 |
+
/**
|
| 790 |
+
* Contacts Collection Class for calls to the contact collection API
|
| 791 |
+
*
|
| 792 |
+
* Includes functions for listing all contacts within the account, specific contact details,
|
| 793 |
+
* also creating, removing, and sending contacts to do not mail.
|
| 794 |
+
*
|
| 795 |
+
*/
|
| 796 |
+
class ContactsCollection
|
| 797 |
+
{
|
| 798 |
+
/**
|
| 799 |
+
* Public function that does a POST to the Contacts collection, passing a contact object
|
| 800 |
+
*
|
| 801 |
+
* @param object $contact - a valid contact object with all required fields
|
| 802 |
+
* @return string $code - returns success or fail code from API server
|
| 803 |
+
*/
|
| 804 |
+
public function createContact($contact)
|
| 805 |
+
{
|
| 806 |
+
$utility = new Utility();
|
| 807 |
+
|
| 808 |
+
$call = $utility->getApiPath() . '/ws/customers/'. $utility->getLogin() .'/contacts';
|
| 809 |
+
$contactStruct = $this->createContactXml(null, $contact);
|
| 810 |
+
$return = $utility->httpPost($call, $contactStruct);
|
| 811 |
+
$code = $return['info']['http_code'];
|
| 812 |
+
return $code;
|
| 813 |
+
}
|
| 814 |
+
/**
|
| 815 |
+
* Public function that deletes a contact, sending the contact to the Do Not Mail List
|
| 816 |
+
*
|
| 817 |
+
* @param object $contact - a valid contact object with a valid contact link
|
| 818 |
+
* @return string $code - returns success or fail code from API server
|
| 819 |
+
*/
|
| 820 |
+
public function deleteContact($contact)
|
| 821 |
+
{
|
| 822 |
+
$utility = new Utility();
|
| 823 |
+
$call = $utility->getApiPath() . $contact->getLink();
|
| 824 |
+
$return = $utility->httpDelete($call);
|
| 825 |
+
$code = $return['info']['http_code'];
|
| 826 |
+
return $code;
|
| 827 |
+
}
|
| 828 |
+
/**
|
| 829 |
+
* Public function that gets contact details of a single contact object passed to it.
|
| 830 |
+
*
|
| 831 |
+
* @param object $contact - a valid contact object with a valid contact link
|
| 832 |
+
* @return object $contact - returns contact object with full details
|
| 833 |
+
*/
|
| 834 |
+
public function listContactDetails($contact)
|
| 835 |
+
{
|
| 836 |
+
$utility = new Utility();
|
| 837 |
+
$call = $utility->getApiPath() . $contact->getLink();
|
| 838 |
+
$return = $utility->httpGet($call);
|
| 839 |
+
$contact = $this->createContactStruct($return['xml']);
|
| 840 |
+
if (!$return)
|
| 841 |
+
{
|
| 842 |
+
return false;
|
| 843 |
+
}
|
| 844 |
+
else
|
| 845 |
+
{
|
| 846 |
+
return $contact;
|
| 847 |
+
}
|
| 848 |
+
}
|
| 849 |
+
/**
|
| 850 |
+
* Public function that gets a list of first 50 contacts in the account
|
| 851 |
+
*
|
| 852 |
+
* @return array $allContacts - an array of two arrays, array 1 is contact objects, array 2 is link for next 50 contacts
|
| 853 |
+
*/
|
| 854 |
+
public function listContacts()
|
| 855 |
+
{
|
| 856 |
+
$utility = new Utility();
|
| 857 |
+
$return = $utility->httpGet($utility->getApiPath() . '/ws/customers/'. $utility->getLogin() .'/contacts');
|
| 858 |
+
$allContacts = array();
|
| 859 |
+
|
| 860 |
+
$contactList = array();
|
| 861 |
+
$pages = array();
|
| 862 |
+
|
| 863 |
+
$parsedReturn = simplexml_load_string($return['xml']);
|
| 864 |
+
|
| 865 |
+
foreach ($parsedReturn->entry as $item)
|
| 866 |
+
{
|
| 867 |
+
$contact = new Contact();
|
| 868 |
+
$contact->setLink($item->link['href']);
|
| 869 |
+
$contact->setId($item->id);
|
| 870 |
+
$contact->setEmailAddress($item->content->Contact->EmailAddress);
|
| 871 |
+
$contact->setFullName($item->content->Contact->Name);
|
| 872 |
+
$contact->setStatus($item->content->Contact->Status);
|
| 873 |
+
$contact->setEmailType($item->Contact->EmailType);
|
| 874 |
+
$contactList[] = $contact;
|
| 875 |
+
}
|
| 876 |
+
|
| 877 |
+
if ($parsedReturn->link[2])
|
| 878 |
+
{
|
| 879 |
+
$pages[] = $parsedReturn->link[2]->Attributes()->href;
|
| 880 |
+
}
|
| 881 |
+
|
| 882 |
+
$allContacts = array($contactList, $pages);
|
| 883 |
+
|
| 884 |
+
return $allContacts;
|
| 885 |
+
}
|
| 886 |
+
/**
|
| 887 |
+
* Public function that gets a list of first 50 contact events in the account of a specific contact event type
|
| 888 |
+
*
|
| 889 |
+
* @param object $contact - valid contact object with valid contact link
|
| 890 |
+
* @param string $type - type must be opens, clicks, sends, optOuts, bounces, or forwards.
|
| 891 |
+
* @return object $contact - returns contact object with fields set with array of the events that were requested
|
| 892 |
+
*/
|
| 893 |
+
public function listContactEvents($contact, $type)
|
| 894 |
+
{
|
| 895 |
+
$utility = new Utility();
|
| 896 |
+
switch ($type)
|
| 897 |
+
{
|
| 898 |
+
case 'opens':
|
| 899 |
+
$call = $utility->httpGet($utility->getApiPath() . $contact->getLink() . "/events/opens");
|
| 900 |
+
$parsedReturn = simplexml_load_string($call['xml']);
|
| 901 |
+
|
| 902 |
+
foreach ($parsedReturn->entry as $item)
|
| 903 |
+
{
|
| 904 |
+
$contact->setOpens(array("CampaignLink" => $item->content->OpenEvent->Campaign->link->Attributes()->href, "EventTime" => $item->content->OpenEvent->EventTime));
|
| 905 |
+
}
|
| 906 |
+
|
| 907 |
+
break;
|
| 908 |
+
case 'clicks':
|
| 909 |
+
$call = $utility->httpGet($utility->getApiPath() . $contact->getLink() . "/events/clicks");
|
| 910 |
+
$parsedReturn = simplexml_load_string($call['xml']);
|
| 911 |
+
|
| 912 |
+
foreach ($parsedReturn->entry as $item)
|
| 913 |
+
{
|
| 914 |
+
$contact->setClicks(array("CampaignLink" => $item->content->ClickEvent->Campaign->link->Attributes()->href, "EventTime" => $item->content->ClickEvent->EventTime, "LinkUrl" => $item->content->ClickEvent->LinkUrl));
|
| 915 |
+
}
|
| 916 |
+
|
| 917 |
+
break;
|
| 918 |
+
case 'bounces':
|
| 919 |
+
$call = $utility->httpGet($utility->getApiPath() . $contact->getLink() . "/events/bounces");
|
| 920 |
+
$parsedReturn = simplexml_load_string($call['xml']);
|
| 921 |
+
|
| 922 |
+
foreach ($parsedReturn->entry as $item)
|
| 923 |
+
{
|
| 924 |
+
$contact->setBounces(array("CampaignLink" => $item->content->BounceEvent->Campaign->link->Attributes()->href, "EventTime" => $item->content->BounceEvent->EventTime, "Code" => $item->content->BounceEvent->Code, "Description" => $item->content->BounceEvent->Description));
|
| 925 |
+
}
|
| 926 |
+
|
| 927 |
+
break;
|
| 928 |
+
case 'optOuts':
|
| 929 |
+
$call = $utility->httpGet($utility->getApiPath() . $contact->getLink() . "/events/optouts");
|
| 930 |
+
$parsedReturn = simplexml_load_string($call['xml']);
|
| 931 |
+
|
| 932 |
+
foreach ($parsedReturn->entry as $item)
|
| 933 |
+
{
|
| 934 |
+
$contact->setOptOuts(array("CampaignLink" => $item->content->OptoutEvent->Campaign->link->Attributes()->href, "EventTime" => $item->content->OptoutEvent->EventTime, "OptOutSource" => $item->content->OptoutEvent->OptOutSource, "OptOutReason" => $item->content->OptoutEvent->OptOutReason));
|
| 935 |
+
}
|
| 936 |
+
break;
|
| 937 |
+
|
| 938 |
+
case 'forwards':
|
| 939 |
+
$call = $utility->httpGet($utility->getApiPath() . $contact->getLink() . "/events/forwards");
|
| 940 |
+
$parsedReturn = simplexml_load_string($call['xml']);
|
| 941 |
+
|
| 942 |
+
foreach ($parsedReturn->entry as $item)
|
| 943 |
+
{
|
| 944 |
+
$contact->setForwards(array("CampaignLink" => $item->content->ForwardEvent->Campaign->link->Attributes()->href, "EventTime" => $item->content->ForwardEvent->EventTime));
|
| 945 |
+
}
|
| 946 |
+
|
| 947 |
+
break;
|
| 948 |
+
case 'sends':
|
| 949 |
+
$call = $utility->httpGet($utility->getApiPath() . $contact->getLink() . "/events/sends");
|
| 950 |
+
$parsedReturn = simplexml_load_string($call['xml']);
|
| 951 |
+
|
| 952 |
+
foreach ($parsedReturn->entry as $item)
|
| 953 |
+
{
|
| 954 |
+
$contact->setSends(array("CampaignLink" => $item->content->SentEvent->Campaign->link->Attributes()->href, "EventTime" => $item->content->SentEvent->EventTime));
|
| 955 |
+
}
|
| 956 |
+
|
| 957 |
+
break;
|
| 958 |
+
}
|
| 959 |
+
return $contact;
|
| 960 |
+
}
|
| 961 |
+
/**
|
| 962 |
+
* Public function that removes a contact from all lists in the account
|
| 963 |
+
*
|
| 964 |
+
* @param object $contact - a valid contact object with a valid contact link
|
| 965 |
+
* @return string $code - returns success or fail code from API server
|
| 966 |
+
*/
|
| 967 |
+
public function removeContact($contact)
|
| 968 |
+
{
|
| 969 |
+
$utility = new Utility();
|
| 970 |
+
$existingContact = $this->getContactDetails($contact);
|
| 971 |
+
$existingContact->removeLists();
|
| 972 |
+
|
| 973 |
+
$contactXml = $this->createContactXml($existingContact->getId(), $existingContact);
|
| 974 |
+
$return = $utility->httpPut($utility->getApiPath() . $existingContact->getLink(), $contactXml);
|
| 975 |
+
$code = $return['info']['http_code'];
|
| 976 |
+
return $code;
|
| 977 |
+
}
|
| 978 |
+
/**
|
| 979 |
+
* Public function that searches for a contact based on their email address
|
| 980 |
+
*
|
| 981 |
+
* @param string $emailAddress - valid email address
|
| 982 |
+
* @return array $searchContacts - an array of two arrays, array 1 is search results, array 2 is link for next 50 contacts
|
| 983 |
+
*/
|
| 984 |
+
public function searchByEmail($emailAddress)
|
| 985 |
+
{
|
| 986 |
+
$utility = new Utility();
|
| 987 |
+
$return = $utility->httpGet($utility->getApiPath() . '/ws/customers/'. $utility->getLogin() .'/contacts?email=' . urlencode($emailAddress));
|
| 988 |
+
$parsedReturn = simplexml_load_string($return['xml']);
|
| 989 |
+
|
| 990 |
+
$email = $parsedReturn->entry->content->Contact->EmailAddress;
|
| 991 |
+
$id = $parsedReturn->entry->link->Attributes();
|
| 992 |
+
|
| 993 |
+
if (!$email)
|
| 994 |
+
{
|
| 995 |
+
return false;
|
| 996 |
+
}
|
| 997 |
+
else
|
| 998 |
+
{
|
| 999 |
+
$searchResults = array();
|
| 1000 |
+
$searcgContacts = array();
|
| 1001 |
+
$pages = array();
|
| 1002 |
+
|
| 1003 |
+
foreach ($parsedReturn->entry as $item)
|
| 1004 |
+
{
|
| 1005 |
+
$contact = new Contact();
|
| 1006 |
+
$contact->setLink($item->link->Attributes()->href);
|
| 1007 |
+
$contact->setId($item->id);
|
| 1008 |
+
$contact->setEmailAddress($item->content->Contact->EmailAddress);
|
| 1009 |
+
$contact->setFullName($item->content->Contact->Name);
|
| 1010 |
+
$contact->setStatus($item->content->Contact->Status);
|
| 1011 |
+
$contact->setEmailType($item->Contact->EmailType);
|
| 1012 |
+
$searchResults[] = $contact;
|
| 1013 |
+
}
|
| 1014 |
+
|
| 1015 |
+
if ($parsedReturn->link[4])
|
| 1016 |
+
{
|
| 1017 |
+
$pages[] = $parsedReturn->link[4]->Attributes()->href;
|
| 1018 |
+
}
|
| 1019 |
+
|
| 1020 |
+
$searchContacts = array($searchResults, $pages);
|
| 1021 |
+
|
| 1022 |
+
return $searchContacts;
|
| 1023 |
+
|
| 1024 |
+
}
|
| 1025 |
+
}
|
| 1026 |
+
/**
|
| 1027 |
+
* Public function that shows a list of contacts updated by date in a list of list type
|
| 1028 |
+
*
|
| 1029 |
+
* @param string $date - valid date
|
| 1030 |
+
* @param string $syncType - valid sync type is listtype or listid
|
| 1031 |
+
* @param string $list - either the list ID if listid is chosen, or the list type, if list type is chosen
|
| 1032 |
+
* @return array $syncContacts - an array of two arrays, array 1 is sync results, array 2 is link for next 50 contacts
|
| 1033 |
+
*/
|
| 1034 |
+
public function syncContacts($date, $syncType, $list)
|
| 1035 |
+
{
|
| 1036 |
+
$utility = new Utility();
|
| 1037 |
+
$return = $utility->httpGet($utility->getApiPath() . '/ws/customers/'. $utility->getLogin() .'/contacts?updatedsince=' . $date . '&' . $syncType . '=' . $list);
|
| 1038 |
+
$parsedReturn = simplexml_load_string($return['xml']);
|
| 1039 |
+
|
| 1040 |
+
$email = $parsedReturn->entry->content->Contact->EmailAddress;
|
| 1041 |
+
$id = $parsedReturn->entry->link->Attributes();
|
| 1042 |
+
|
| 1043 |
+
$searchResults = array();
|
| 1044 |
+
$syncContacts = array();
|
| 1045 |
+
$pages = array();
|
| 1046 |
+
|
| 1047 |
+
foreach ($parsedReturn->entry as $item)
|
| 1048 |
+
{
|
| 1049 |
+
$contact = new Contact();
|
| 1050 |
+
$contact->setLink($item->link->Attributes()->href);
|
| 1051 |
+
$contact->setId($item->id);
|
| 1052 |
+
$contact->setEmailAddress($item->content->Contact->EmailAddress);
|
| 1053 |
+
$contact->setFullName($item->content->Contact->Name);
|
| 1054 |
+
$contact->setStatus($item->content->Contact->Status);
|
| 1055 |
+
$contact->setEmailType($item->Contact->EmailType);
|
| 1056 |
+
$searchResults[] = $contact;
|
| 1057 |
+
}
|
| 1058 |
+
|
| 1059 |
+
if ($parsedReturn->link[4])
|
| 1060 |
+
{
|
| 1061 |
+
$pages[] = $parsedReturn->link[4]->Attributes()->href;
|
| 1062 |
+
}
|
| 1063 |
+
|
| 1064 |
+
$syncContacts = array($searchResults, $pages);
|
| 1065 |
+
return $syncContacts;
|
| 1066 |
+
}
|
| 1067 |
+
/**
|
| 1068 |
+
* Public function that updates a contact
|
| 1069 |
+
*
|
| 1070 |
+
* @param string $contactId - valid contact ID of the contact that needs to be updated
|
| 1071 |
+
* @param object $contact - valid contact object of the new updates to the contact
|
| 1072 |
+
* @return string $code - success or fail message from the API server
|
| 1073 |
+
*/
|
| 1074 |
+
public function updateContact($contactId, $contact)
|
| 1075 |
+
{
|
| 1076 |
+
$utility = new Utility();
|
| 1077 |
+
$existingContact = $this->listContactDetails($contact);
|
| 1078 |
+
$contactXml = $this->createContactXml($existingContact->getId(), $contact);
|
| 1079 |
+
$return = $utility->httpPut($utility->getApiPath() . $existingContact->getLink(), $contactXml);
|
| 1080 |
+
$code = $return['info']['http_code'];
|
| 1081 |
+
return $code;
|
| 1082 |
+
}
|
| 1083 |
+
/**
|
| 1084 |
+
* Private function that creates a contact object from XML
|
| 1085 |
+
*
|
| 1086 |
+
* @param string $contactXml - Valid contact XML
|
| 1087 |
+
* @return object $contactStruct - returns a valid contact object
|
| 1088 |
+
*/
|
| 1089 |
+
private function createContactStruct($contactXml)
|
| 1090 |
+
{
|
| 1091 |
+
$fullContact = array();
|
| 1092 |
+
$parsedReturn = simplexml_load_string($contactXml);
|
| 1093 |
+
$fullContact['link'] = ($parsedReturn->link->Attributes()->href);
|
| 1094 |
+
$fullContact['id'] = ($parsedReturn->id);
|
| 1095 |
+
$fullContact['email_address'] = ($parsedReturn->content->Contact->EmailAddress);
|
| 1096 |
+
$fullContact['first_name'] = ($parsedReturn->content->Contact->FirstName);
|
| 1097 |
+
$fullContact['last_name'] = ($parsedReturn->content->Contact->LastName);
|
| 1098 |
+
$fullContact['middle_name'] = ($parsedReturn->content->Contact->MiddleName);
|
| 1099 |
+
$fullContact['company_name'] = ($parsedReturn->content->Contact->CompanyName);
|
| 1100 |
+
$fullContact['job_title'] = ($parsedReturn->cokntent->Contact->JobTitle);
|
| 1101 |
+
$fullContact['home_number'] = ($parsedReturn->content->Contact->HomePhone);
|
| 1102 |
+
$fullContact['work_number'] = ($parsedReturn->content->Contact->WorkPhone);
|
| 1103 |
+
$fullContact['address_line_1'] = ($parsedReturn->content->Contact->Addr1);
|
| 1104 |
+
$fullContact['address_line_2'] = ($parsedReturn->content->Contact->Addr2);
|
| 1105 |
+
$fullContact['address_line_3'] = ($parsedReturn->content->Contact->Addr3);
|
| 1106 |
+
$fullContact['city_name'] = ((string) $parsedReturn->content->Contact->City);
|
| 1107 |
+
$fullContact['state_code'] = ((string) $parsedReturn->content->Contact->StateCode);
|
| 1108 |
+
$fullContact['state_name'] = ((string) $parsedReturn->content->Contact->StateName);
|
| 1109 |
+
$fullContact['country_code'] = ($parsedReturn->content->Contact->CountryCode);
|
| 1110 |
+
$fullContact['zip_code'] = ($parsedReturn->content->Contact->PostalCode);
|
| 1111 |
+
$fullContact['sub_zip_code'] = ($parsedReturn->content->Contact->SubPostalCode);
|
| 1112 |
+
$fullContact['custom_field_1'] = ($parsedReturn->content->Contact->$customField1);
|
| 1113 |
+
$fullContact['custom_field_2'] = ($parsedReturn->content->Contact->$customField2);
|
| 1114 |
+
$fullContact['custom_field_3'] = ($parsedReturn->content->Contact->$customField3);
|
| 1115 |
+
$fullContact['custom_field_4'] = ($parsedReturn->content->Contact->$customField4);
|
| 1116 |
+
$fullContact['custom_field_5'] = ($parsedReturn->content->Contact->$customField5);
|
| 1117 |
+
$fullContact['custom_field_6'] = ($parsedReturn->content->Contact->$customField6);
|
| 1118 |
+
$fullContact['custom_field_7'] = ($parsedReturn->content->Contact->$customField7);
|
| 1119 |
+
$fullContact['custom_field_8'] = ($parsedReturn->content->Contact->$customField8);
|
| 1120 |
+
$fullContact['custom_field_9'] = ($parsedReturn->content->Contact->$customField9);
|
| 1121 |
+
$fullContact['custom_field_10'] = ($parsedReturn->content->Contact->$customField10);
|
| 1122 |
+
$fullContact['custom_field_11'] = ($parsedReturn->content->Contact->$customField11);
|
| 1123 |
+
$fullContact['custom_field_12'] = ($parsedReturn->content->Contact->$customField12);
|
| 1124 |
+
$fullContact['custom_field_13'] = ($parsedReturn->content->Contact->$customField13);
|
| 1125 |
+
$fullContact['custom_field_14'] = ($parsedReturn->content->Contact->$customField14);
|
| 1126 |
+
$fullContact['custom_field_15'] = ($parsedReturn->content->Contact->$customField15);
|
| 1127 |
+
$fullContact['notes'] = ($parsedReturn->content->Contact->Note);
|
| 1128 |
+
$fullContact['mail_type'] = ($parsedReturn->content->Contact->EmailType);
|
| 1129 |
+
$fullContact['status'] = ($parsedReturn->content->Contact->Status);
|
| 1130 |
+
|
| 1131 |
+
if ($parsedReturn->content->Contact->ContactLists->ContactList)
|
| 1132 |
+
{
|
| 1133 |
+
foreach ($parsedReturn->content->Contact->ContactLists->ContactList as $item)
|
| 1134 |
+
{
|
| 1135 |
+
$fullContact['lists'][] = (trim((string) $item->Attributes()));
|
| 1136 |
+
}
|
| 1137 |
+
}
|
| 1138 |
+
|
| 1139 |
+
$contact = new Contact($fullContact);
|
| 1140 |
+
return $contact;
|
| 1141 |
+
}
|
| 1142 |
+
/**
|
| 1143 |
+
* Private function that creates contact XML
|
| 1144 |
+
*
|
| 1145 |
+
* @param string $id - optional valid contact ID, used for updating a contact
|
| 1146 |
+
* @param object $contact - valid contact object
|
| 1147 |
+
* @return string $entry - valid XML of a contact
|
| 1148 |
+
*/
|
| 1149 |
+
private function createContactXml($id, $contact)
|
| 1150 |
+
{
|
| 1151 |
+
$utility = new Utility();
|
| 1152 |
+
|
| 1153 |
+
if ( empty($id)) {
|
| 1154 |
+
$id = "urn:uuid:E8553C09F4xcvxCCC53F481214230867087";
|
| 1155 |
+
}
|
| 1156 |
+
|
| 1157 |
+
$update_date = date("Y-m-d").'T'.date("H:i:s").'+01:00';
|
| 1158 |
+
$xml_string = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><entry xmlns='http://www.w3.org/2005/Atom'></entry>";
|
| 1159 |
+
$xml_object = simplexml_load_string($xml_string);
|
| 1160 |
+
$title_node = $xml_object->addChild("title", htmlspecialchars(("TitleNode"), ENT_QUOTES, 'UTF-8'));
|
| 1161 |
+
$updated_node = $xml_object->addChild("updated", htmlspecialchars(($update_date), ENT_QUOTES, 'UTF-8'));
|
| 1162 |
+
$author_node = $xml_object->addChild("author");
|
| 1163 |
+
$author_name = $author_node->addChild("name", ("CTCT Samples"));
|
| 1164 |
+
$id_node = $xml_object->addChild("id", htmlspecialchars(((string) $id),ENT_QUOTES, 'UTF-8'));
|
| 1165 |
+
$summary_node = $xml_object->addChild("summary", htmlspecialchars(("Customer document"),ENT_QUOTES, 'UTF-8'));
|
| 1166 |
+
$summary_node->addAttribute("type", "text");
|
| 1167 |
+
$content_node = $xml_object->addChild("content");
|
| 1168 |
+
$content_node->addAttribute("type", "application/vnd.ctct+xml");
|
| 1169 |
+
$contact_node = $content_node->addChild("Contact", htmlspecialchars(("Customer document"), ENT_QUOTES, 'UTF-8'));
|
| 1170 |
+
$contact_node->addAttribute("xmlns", "http://ws.constantcontact.com/ns/1.0/");
|
| 1171 |
+
$email_node = $contact_node->addChild("EmailAddress", htmlspecialchars(($contact->getEmailAddress()), ENT_QUOTES, 'UTF-8'));
|
| 1172 |
+
$fname_node = $contact_node->addChild("FirstName", urldecode(htmlspecialchars(($contact->getFirstName()), ENT_QUOTES, 'UTF-8')));
|
| 1173 |
+
$lname_node = $contact_node->addChild("LastName", urldecode(htmlspecialchars(($contact->getLastName()), ENT_QUOTES, 'UTF-8')));
|
| 1174 |
+
$lname_node = $contact_node->addChild("MiddleName", urldecode(htmlspecialchars(($contact->getMiddleName()), ENT_QUOTES, 'UTF-8')));
|
| 1175 |
+
$lname_node = $contact_node->addChild("CompanyName", urldecode(htmlspecialchars(($contact->getCompanyName()), ENT_QUOTES, 'UTF-8')));
|
| 1176 |
+
$lname_node = $contact_node->addChild("JobTitle", urldecode(htmlspecialchars(($contact->getJobTitle()), ENT_QUOTES, 'UTF-8')));
|
| 1177 |
+
|
| 1178 |
+
if ($params['status'] == 'Do Not Mail')
|
| 1179 |
+
{
|
| 1180 |
+
$utility->setActionBy('ACTION_BY_CONTACT');
|
| 1181 |
+
}
|
| 1182 |
+
|
| 1183 |
+
$optin_node = $contact_node->addChild("OptInSource", htmlspecialchars($utility->getActionBy()));
|
| 1184 |
+
$hn_node = $contact_node->addChild("HomePhone", htmlspecialchars($contact->getHomeNumber(), ENT_QUOTES, 'UTF-8'));
|
| 1185 |
+
$wn_node = $contact_node->addChild("WorkPhone", htmlspecialchars($contact->getWorkNumber(), ENT_QUOTES, 'UTF-8'));
|
| 1186 |
+
$ad1_node = $contact_node->addChild("Addr1", htmlspecialchars($contact->getAddr1(), ENT_QUOTES, 'UTF-8'));
|
| 1187 |
+
$ad2_node = $contact_node->addChild("Addr2", htmlspecialchars($contact->getAddr2(), ENT_QUOTES, 'UTF-8'));
|
| 1188 |
+
$ad3_node = $contact_node->addChild("Addr3", htmlspecialchars($contact->getAddr3(), ENT_QUOTES, 'UTF-8'));
|
| 1189 |
+
$city_node = $contact_node->addChild("City", htmlspecialchars($contact->getCity(), ENT_QUOTES, 'UTF-8'));
|
| 1190 |
+
$state_node = $contact_node->addChild("StateCode", htmlspecialchars($contact->getStateCode(), ENT_QUOTES, 'UTF-8'));
|
| 1191 |
+
$state_name = $contact_node->addChild("StateName", htmlspecialchars($contact->getStateName(), ENT_QUOTES, 'UTF-8'));
|
| 1192 |
+
$ctry_node = $contact_node->addChild("CountryCode", htmlspecialchars($contact->getCountryCode(), ENT_QUOTES, 'UTF-8'));
|
| 1193 |
+
$zip_node = $contact_node->addChild("PostalCode", htmlspecialchars($contact->getPostalCode(), ENT_QUOTES, 'UTF-8'));
|
| 1194 |
+
$subzip_node = $contact_node->addChild("SubPostalCode", htmlspecialchars($contact->getSubPostalCode(), ENT_QUOTES, 'UTF-8'));
|
| 1195 |
+
$note_node = $contact_node->addChild("Note", htmlspecialchars($contact->getNotes(), ENT_QUOTES, 'UTF-8'));
|
| 1196 |
+
$emailtype_node = $contact_node->addChild("EmailType", htmlspecialchars($contact->getEmailType(), ENT_QUOTES, 'UTF-8'));
|
| 1197 |
+
$customfield1_node = $contact_node->addChild("CustomField1", htmlspecialchars(($contact->getCustomField1()), ENT_QUOTES, 'UTF-8'));
|
| 1198 |
+
$customfield2_node = $contact_node->addChild("CustomField2", htmlspecialchars(($contact->getCustomField2()), ENT_QUOTES, 'UTF-8'));
|
| 1199 |
+
$customfield3_node = $contact_node->addChild("CustomField3", htmlspecialchars(($contact->getCustomField3()), ENT_QUOTES, 'UTF-8'));
|
| 1200 |
+
$customfield4_node = $contact_node->addChild("CustomField4", htmlspecialchars(($contact->getCustomField4()), ENT_QUOTES, 'UTF-8'));
|
| 1201 |
+
$customfield5_node = $contact_node->addChild("CustomField5", htmlspecialchars(($contact->getCustomField5()), ENT_QUOTES, 'UTF-8'));
|
| 1202 |
+
$customfield6_node = $contact_node->addChild("CustomField6", htmlspecialchars(($contact->getCustomField6()), ENT_QUOTES, 'UTF-8'));
|
| 1203 |
+
$customfield7_node = $contact_node->addChild("CustomField7", htmlspecialchars(($contact->getCustomField7()), ENT_QUOTES, 'UTF-8'));
|
| 1204 |
+
$customfield8_node = $contact_node->addChild("CustomField8", htmlspecialchars(($contact->getCustomField8()), ENT_QUOTES, 'UTF-8'));
|
| 1205 |
+
$customfield9_node = $contact_node->addChild("CustomField9", htmlspecialchars(($contact->getCustomField9()), ENT_QUOTES, 'UTF-8'));
|
| 1206 |
+
$customfield10_node = $contact_node->addChild("CustomField10", htmlspecialchars(($contact->getCustomField10()), ENT_QUOTES, 'UTF-8'));
|
| 1207 |
+
$customfield11_node = $contact_node->addChild("CustomField11", htmlspecialchars(($contact->getCustomField11()), ENT_QUOTES, 'UTF-8'));
|
| 1208 |
+
$customfield12_node = $contact_node->addChild("CustomField12", htmlspecialchars(($contact->getCustomField12()), ENT_QUOTES, 'UTF-8'));
|
| 1209 |
+
$customfield13_node = $contact_node->addChild("CustomField13", htmlspecialchars(($contact->getCustomField13()), ENT_QUOTES, 'UTF-8'));
|
| 1210 |
+
$customfield14_node = $contact_node->addChild("CustomField14", htmlspecialchars(($contact->getCustomField14()), ENT_QUOTES, 'UTF-8'));
|
| 1211 |
+
$customfield15_node = $contact_node->addChild("CustomField15", htmlspecialchars(($contact->getCustomField15()), ENT_QUOTES, 'UTF-8'));
|
| 1212 |
+
|
| 1213 |
+
$contactlists_node = $contact_node->addChild("ContactLists");
|
| 1214 |
+
|
| 1215 |
+
foreach ($contact->getLists() as $tmp)
|
| 1216 |
+
{
|
| 1217 |
+
$contactlist_node = $contactlists_node->addChild("ContactList");
|
| 1218 |
+
$contactlist_node->addAttribute("id", $tmp);
|
| 1219 |
+
}
|
| 1220 |
+
|
| 1221 |
+
$entry = $xml_object->asXML();
|
| 1222 |
+
return $entry;
|
| 1223 |
+
}
|
| 1224 |
+
}
|
| 1225 |
+
/**
|
| 1226 |
+
* Contact class defines a contact object
|
| 1227 |
+
*
|
| 1228 |
+
* Defines a contact object, includes all contact variables as well as the
|
| 1229 |
+
* getters and setters for variables
|
| 1230 |
+
*
|
| 1231 |
+
*/
|
| 1232 |
+
class Contact
|
| 1233 |
+
{
|
| 1234 |
+
/**
|
| 1235 |
+
* Construct function for the Contact Class
|
| 1236 |
+
*
|
| 1237 |
+
* @param array $params - an array of variables that set up a contact object
|
| 1238 |
+
* @return object contact object with passed variables set to the object
|
| 1239 |
+
*/
|
| 1240 |
+
public function __construct($params = array())
|
| 1241 |
+
{
|
| 1242 |
+
$utility = new Utility();
|
| 1243 |
+
if ($params['status'] == 'Do Not Mail')
|
| 1244 |
+
{
|
| 1245 |
+
$utility->setActionBy('ACTION_BY_CONTACT');
|
| 1246 |
+
}
|
| 1247 |
+
$this->setLink($params['link']);
|
| 1248 |
+
$this->setId($params['id']);
|
| 1249 |
+
$this->setEmailAddress($params['email_address']);
|
| 1250 |
+
$this->setFirstName($params['first_name']);
|
| 1251 |
+
$this->setMiddleName($params['middle_name']);
|
| 1252 |
+
$this->setLastName($params['last_name']);
|
| 1253 |
+
$this->setCompanyName($params['company_name']);
|
| 1254 |
+
$this->setJobTitle($params['job_title']);
|
| 1255 |
+
$this->setHomeNumber($params['home_number']);
|
| 1256 |
+
$this->setWorkNumber($params['work_number']);
|
| 1257 |
+
$this->setAddr1($params['address_line_1']);
|
| 1258 |
+
$this->setAddr2($params['address_line_2']);
|
| 1259 |
+
$this->setAddr3($params['address_line_3']);
|
| 1260 |
+
$this->setCity($params['city_name']);
|
| 1261 |
+
$this->setStateCode($params['state_code']);
|
| 1262 |
+
$this->setStateName($params['state_name']);
|
| 1263 |
+
$this->setCountryCode($params['country_code']);
|
| 1264 |
+
$this->setPostalCode($params['zip_code']);
|
| 1265 |
+
$this->setSubPostalCode($params['sub_zip_code']);
|
| 1266 |
+
$this->setNotes($params['notes']);
|
| 1267 |
+
$this->setCustomField1($params['custom_field_1']);
|
| 1268 |
+
$this->setCustomField2($params['custom_field_2']);
|
| 1269 |
+
$this->setCustomField3($params['custom_field_3']);
|
| 1270 |
+
$this->setCustomField4($params['custom_field_4']);
|
| 1271 |
+
$this->setCustomField5($params['custom_field_5']);
|
| 1272 |
+
$this->setCustomField6($params['custom_field_6']);
|
| 1273 |
+
$this->setCustomField7($params['custom_field_7']);
|
| 1274 |
+
$this->setCustomField8($params['custom_field_8']);
|
| 1275 |
+
$this->setCustomField9($params['custom_field_9']);
|
| 1276 |
+
$this->setCustomField10($params['custom_field_10']);
|
| 1277 |
+
$this->setCustomField11($params['custom_field_11']);
|
| 1278 |
+
$this->setCustomField12($params['custom_field_12']);
|
| 1279 |
+
$this->setCustomField13($params['custom_field_13']);
|
| 1280 |
+
$this->setCustomField14($params['custom_field_14']);
|
| 1281 |
+
$this->setCustomField15($params['custom_field_15']);
|
| 1282 |
+
$this->setEmailType($params['mail_type']);
|
| 1283 |
+
$this->setOptInSource($utility->getActionBy());
|
| 1284 |
+
|
| 1285 |
+
if ($params['lists'])
|
| 1286 |
+
{
|
| 1287 |
+
foreach ($params['lists'] as $tmp)
|
| 1288 |
+
{
|
| 1289 |
+
$this->setLists($tmp);
|
| 1290 |
+
}
|
| 1291 |
+
}
|
| 1292 |
+
|
| 1293 |
+
return $this;
|
| 1294 |
+
}
|
| 1295 |
+
|
| 1296 |
+
private $link;
|
| 1297 |
+
private $id;
|
| 1298 |
+
private $status;
|
| 1299 |
+
private $emailAddress;
|
| 1300 |
+
private $emailType;
|
| 1301 |
+
private $firstName;
|
| 1302 |
+
private $middleName;
|
| 1303 |
+
private $lastName;
|
| 1304 |
+
private $fullName;
|
| 1305 |
+
private $jobTitle;
|
| 1306 |
+
private $companyName;
|
| 1307 |
+
private $homeNumber;
|
| 1308 |
+
private $workNumber;
|
| 1309 |
+
private $addr1;
|
| 1310 |
+
private $addr2;
|
| 1311 |
+
private $addr3;
|
| 1312 |
+
private $city;
|
| 1313 |
+
private $stateCode;
|
| 1314 |
+
private $stateName;
|
| 1315 |
+
private $countryCode;
|
| 1316 |
+
private $countryName;
|
| 1317 |
+
private $postalCode;
|
| 1318 |
+
private $subPostalCode;
|
| 1319 |
+
private $notes;
|
| 1320 |
+
private $customField1;
|
| 1321 |
+
private $customField2;
|
| 1322 |
+
private $customField3;
|
| 1323 |
+
private $customField4;
|
| 1324 |
+
private $customField5;
|
| 1325 |
+
private $customField6;
|
| 1326 |
+
private $customField7;
|
| 1327 |
+
private $customField8;
|
| 1328 |
+
private $customField9;
|
| 1329 |
+
private $customField10;
|
| 1330 |
+
private $customField11;
|
| 1331 |
+
private $customField12;
|
| 1332 |
+
private $customField13;
|
| 1333 |
+
private $customField14;
|
| 1334 |
+
private $customField15;
|
| 1335 |
+
private $contactLists;
|
| 1336 |
+
private $confirmed;
|
| 1337 |
+
private $optInSource;
|
| 1338 |
+
private $lists = array();
|
| 1339 |
+
private $bounces = array();
|
| 1340 |
+
private $clicks = array();
|
| 1341 |
+
private $forwards = array();
|
| 1342 |
+
private $opens = array();
|
| 1343 |
+
private $optOuts = array();
|
| 1344 |
+
private $sends = array();
|
| 1345 |
+
|
| 1346 |
+
public function setLink( $value ) { $this->link = $value; }
|
| 1347 |
+
public function getLink() { return $this->link; }
|
| 1348 |
+
|
| 1349 |
+
public function setId( $value ) { $this->id = $value; }
|
| 1350 |
+
public function getId() { return $this->id; }
|
| 1351 |
+
|
| 1352 |
+
public function setStatus( $value ) { $this->status = $value; }
|
| 1353 |
+
public function getStatus() { return $this->status; }
|
| 1354 |
+
|
| 1355 |
+
public function setEmailAddress( $value ) { $this->emailAddress = $value; }
|
| 1356 |
+
public function getEmailAddress() { return $this->emailAddress; }
|
| 1357 |
+
|
| 1358 |
+
public function setEmailType( $value ) { $this->emailType = $value; }
|
| 1359 |
+
public function getEmailType() { return $this->emailType; }
|
| 1360 |
+
|
| 1361 |
+
public function setFullName( $value ) { $this->fullName = $value; }
|
| 1362 |
+
public function getFullName() { return $this->fullName; }
|
| 1363 |
+
|
| 1364 |
+
public function setFirstName( $value ) { $this->firstName = $value; }
|
| 1365 |
+
public function getFirstName() { return $this->firstName; }
|
| 1366 |
+
|
| 1367 |
+
public function setMiddleName( $value ) { $this->middleName = $value; }
|
| 1368 |
+
public function getMiddleName() { return $this->middleName; }
|
| 1369 |
+
|
| 1370 |
+
public function setLastName( $value ) { $this->lastName = $value; }
|
| 1371 |
+
public function getLastName() { return $this->lastName; }
|
| 1372 |
+
|
| 1373 |
+
public function setJobTitle( $value ) { $this->jobTitle = $value; }
|
| 1374 |
+
public function getJobTitle() { return $this->jobTitle; }
|
| 1375 |
+
|
| 1376 |
+
public function setCompanyName( $value ) { $this->companyName = $value; }
|
| 1377 |
+
public function getCompanyName() { return $this->companyName; }
|
| 1378 |
+
|
| 1379 |
+
public function setHomeNumber( $value ) { $this->homeNumber = $value; }
|
| 1380 |
+
public function getHomeNumber() { return $this->homeNumber; }
|
| 1381 |
+
|
| 1382 |
+
public function setWorkNumber( $value ) { $this->workNumber = $value; }
|
| 1383 |
+
public function getWorkNumber() { return $this->workNumber; }
|
| 1384 |
+
|
| 1385 |
+
public function setAddr1( $value ) { $this->addr1 = $value; }
|
| 1386 |
+
public function getAddr1() { return $this->addr1; }
|
| 1387 |
+
|
| 1388 |
+
public function setAddr2( $value ) { $this->addr2 = $value; }
|
| 1389 |
+
public function getAddr2() { return $this->addr2; }
|
| 1390 |
+
|
| 1391 |
+
public function setAddr3( $value ) { $this->addr3 = $value; }
|
| 1392 |
+
public function getAddr3() { return $this->addr3; }
|
| 1393 |
+
|
| 1394 |
+
public function setCity( $value ) { $this->city = $value; }
|
| 1395 |
+
public function getCity() { return $this->city; }
|
| 1396 |
+
|
| 1397 |
+
public function setStateCode( $value ) { $this->stateCode = $value; }
|
| 1398 |
+
public function getStateCode() { return $this->stateCode; }
|
| 1399 |
+
|
| 1400 |
+
public function setStateName( $value ) { $this->stateName = $value; }
|
| 1401 |
+
public function getStateName() { return $this->stateName; }
|
| 1402 |
+
|
| 1403 |
+
public function setCountryCode( $value ) { $this->countryCode = $value; }
|
| 1404 |
+
public function getCountryCode() { return $this->countryCode; }
|
| 1405 |
+
|
| 1406 |
+
public function setCountryName( $value ) { $this->countryName = $value; }
|
| 1407 |
+
public function getCountryName() { return $this->countryName; }
|
| 1408 |
+
|
| 1409 |
+
public function setPostalCode( $value ) { $this->postalCode = $value; }
|
| 1410 |
+
public function getPostalCode() { return $this->postalCode; }
|
| 1411 |
+
|
| 1412 |
+
public function setSubPostalCode( $value ) { $this->subPostalCode = $value; }
|
| 1413 |
+
public function getSubPostalCode() { return $this->subPostalCode; }
|
| 1414 |
+
|
| 1415 |
+
public function setNotes( $value ) { $this->notes = $value; }
|
| 1416 |
+
public function getNotes() { return $this->notes; }
|
| 1417 |
+
|
| 1418 |
+
public function setCustomField1( $value ) { $this->customField1 = $value; }
|
| 1419 |
+
public function getCustomField1() { return $this->customField1; }
|
| 1420 |
+
|
| 1421 |
+
public function setCustomField2( $value ) { $this->customField2 = $value; }
|
| 1422 |
+
public function getCustomField2() { return $this->customField2; }
|
| 1423 |
+
|
| 1424 |
+
public function setCustomField3( $value ) { $this->customField3 = $value; }
|
| 1425 |
+
public function getCustomField3() { return $this->customField3; }
|
| 1426 |
+
|
| 1427 |
+
public function setCustomField4( $value ) { $this->customField4 = $value; }
|
| 1428 |
+
public function getCustomField4() { return $this->customField4; }
|
| 1429 |
+
|
| 1430 |
+
public function setCustomField5( $value ) { $this->customField5 = $value; }
|
| 1431 |
+
public function getCustomField5() { return $this->customField5; }
|
| 1432 |
+
|
| 1433 |
+
public function setCustomField6( $value ) { $this->customField6 = $value; }
|
| 1434 |
+
public function getCustomField6() { return $this->customField6; }
|
| 1435 |
+
|
| 1436 |
+
public function setCustomField7( $value ) { $this->customField7 = $value; }
|
| 1437 |
+
public function getCustomField7() { return $this->customField7; }
|
| 1438 |
+
|
| 1439 |
+
public function setCustomField8( $value ) { $this->customField8 = $value; }
|
| 1440 |
+
public function getCustomField8() { return $this->customField8; }
|
| 1441 |
+
|
| 1442 |
+
public function setCustomField9( $value ) { $this->customField9 = $value; }
|
| 1443 |
+
public function getCustomField9() { return $this->customField9; }
|
| 1444 |
+
|
| 1445 |
+
public function setCustomField10( $value ) { $this->customField10 = $value; }
|
| 1446 |
+
public function getCustomField10() { return $this->customField10; }
|
| 1447 |
+
|
| 1448 |
+
public function setCustomField11( $value ) { $this->customField11 = $value; }
|
| 1449 |
+
public function getCustomField11() { return $this->customField11; }
|
| 1450 |
+
|
| 1451 |
+
public function setCustomField12( $value ) { $this->customField12 = $value; }
|
| 1452 |
+
public function getCustomField12() { return $this->customField12; }
|
| 1453 |
+
|
| 1454 |
+
public function setCustomField13( $value ) { $this->customField13 = $value; }
|
| 1455 |
+
public function getCustomField13() { return $this->customField13; }
|
| 1456 |
+
|
| 1457 |
+
public function setCustomField14( $value ) { $this->customField14 = $value; }
|
| 1458 |
+
public function getCustomField14() { return $this->customField14; }
|
| 1459 |
+
|
| 1460 |
+
public function setCustomField15( $value ) { $this->customField15 = $value; }
|
| 1461 |
+
public function getCustomField15() { return $this->customField15; }
|
| 1462 |
+
|
| 1463 |
+
public function setConfirmed( $value ) { $this->confirmed = $value; }
|
| 1464 |
+
public function getConfirmed() { return $this->confirmed; }
|
| 1465 |
+
|
| 1466 |
+
public function setLists( $value ) { $this->lists[] = $value; }
|
| 1467 |
+
public function getLists() { return $this->lists; }
|
| 1468 |
+
public function removeLists() { $this->lists=""; }
|
| 1469 |
+
|
| 1470 |
+
public function setBounces( $value ) { $this->bounces[] = $value; }
|
| 1471 |
+
public function getBounces() { return $this->bounces; }
|
| 1472 |
+
|
| 1473 |
+
public function setClicks( $value ) { $this->clicks[] = $value; }
|
| 1474 |
+
public function getClicks() { return $this->clicks; }
|
| 1475 |
+
|
| 1476 |
+
public function setForwards( $value ) { $this->forwards[] = $value; }
|
| 1477 |
+
public function getForwards() { return $this->forwards; }
|
| 1478 |
+
|
| 1479 |
+
public function setOpens( $value ) { $this->opens[] = $value; }
|
| 1480 |
+
public function getOpens() { return $this->opens; }
|
| 1481 |
+
|
| 1482 |
+
public function setOptOuts( $value ) { $this->optOuts[] = $value; }
|
| 1483 |
+
public function getOptOuts() { return $this->optOuts; }
|
| 1484 |
+
|
| 1485 |
+
public function setSends( $value ) { $this->sends[] = $value; }
|
| 1486 |
+
public function getSends() { return $this->sends; }
|
| 1487 |
+
|
| 1488 |
+
public function setOptInSource( $value ) { $this->optInSource = $value; }
|
| 1489 |
+
public function getOptInSource15() { return $this->optInSource; }
|
| 1490 |
+
|
| 1491 |
+
}
|
| 1492 |
+
/**
|
| 1493 |
+
* Campaign class defines a campaign object
|
| 1494 |
+
*
|
| 1495 |
+
* Defines a campaign object, includes all campaign variables as well as the
|
| 1496 |
+
* getters and setters for variables
|
| 1497 |
+
*
|
| 1498 |
+
*/
|
| 1499 |
+
class Campaign
|
| 1500 |
+
{
|
| 1501 |
+
/**
|
| 1502 |
+
* Construct function for the Campaign Class
|
| 1503 |
+
*
|
| 1504 |
+
* @param array $params - an array of variables that set up a campaign object
|
| 1505 |
+
* @return object campaign object with passed variables set to the object
|
| 1506 |
+
*/
|
| 1507 |
+
public function __construct($params = array())
|
| 1508 |
+
{
|
| 1509 |
+
$this->setId($params['id']);
|
| 1510 |
+
$this->setLink($params['link']);
|
| 1511 |
+
$this->setCampaignName($params['campaign_name']);
|
| 1512 |
+
$this->setStatus($params['status']);
|
| 1513 |
+
$this->setCampaignDate($params['campaign_date']);
|
| 1514 |
+
$this->setLastEditDate($params['last_edit_date']);
|
| 1515 |
+
$this->setCampaignSent($params['campaign_sent']);
|
| 1516 |
+
$this->setCampaignOpens($params['campaign_opens']);
|
| 1517 |
+
$this->setCampaignClicks($params['campaign_clicks']);
|
| 1518 |
+
$this->setCampaignBounces($params['campaign_bounces']);
|
| 1519 |
+
$this->setCampaignForwards($params['campaign_forwards']);
|
| 1520 |
+
$this->setCampaignOptOuts($params['campaign_optouts']);
|
| 1521 |
+
$this->setCampaignSpamReports($params['campaign_spamreports']);
|
| 1522 |
+
$this->setSubject($params['subject']);
|
| 1523 |
+
$this->setFromName($params['from_name']);
|
| 1524 |
+
$this->setCampaignType($params['campaign_type']);
|
| 1525 |
+
$this->setVawp($params['view_as_web_page']);
|
| 1526 |
+
$this->setVawpLinkText($params['vawp_link_text']);
|
| 1527 |
+
$this->setVawpText($params['vawp_text']);
|
| 1528 |
+
$this->setPermissionReminder($params['permission_reminder']);
|
| 1529 |
+
$this->setPermissionReminderText($params['permission_reminder_txt']);
|
| 1530 |
+
$this->setGreetingSalutation($params['greeting_salutation']);
|
| 1531 |
+
$this->setGreetingName($params['greeting_name']);
|
| 1532 |
+
$this->setGreetingString($params['greeting_string']);
|
| 1533 |
+
$this->setOrgName($params['org_name']);
|
| 1534 |
+
$this->setOrgAddr1($params['org_address_1']);
|
| 1535 |
+
$this->setOrgAddr2($params['org_address_2']);
|
| 1536 |
+
$this->setOrgAddr3($params['org_address_3']);
|
| 1537 |
+
$this->setOrgCity($params['org_city']);
|
| 1538 |
+
$this->setOrgState($params['org_state']);
|
| 1539 |
+
$this->setOrgInternationalState($params['org_international_state']);
|
| 1540 |
+
$this->setOrgCountry($params['org_country']);
|
| 1541 |
+
$this->setOrgPostalCode($params['org_postal_code']);
|
| 1542 |
+
$this->setIncForwardEmail($params['include_forward_email']);
|
| 1543 |
+
$this->setForwardEmailLinkText($params['forward_email_link_text']);
|
| 1544 |
+
$this->setIncSubscribeLink($params['include_subscribe_link']);
|
| 1545 |
+
$this->setSubscribeLinkText($params['subscribe_link_text']);
|
| 1546 |
+
$this->setEmailContentFormat($params['email_content_format']);
|
| 1547 |
+
$this->setEmailContent($params['email_content']);
|
| 1548 |
+
$this->setTextVersionContent($params['text_version_content']);
|
| 1549 |
+
$this->setStyleSheet($params['style_sheet']);
|
| 1550 |
+
|
| 1551 |
+
if ($params['lists'])
|
| 1552 |
+
{
|
| 1553 |
+
foreach ($params['lists'] as $tmp)
|
| 1554 |
+
{
|
| 1555 |
+
$this->setLists($tmp);
|
| 1556 |
+
}
|
| 1557 |
+
}
|
| 1558 |
+
//From and Reply Addresses must be Verified addresses
|
| 1559 |
+
//These can be used from getVerifiedAddresses() in the settingsCollection class
|
| 1560 |
+
$this->setFromEmailAddress($params['frm_addr']);
|
| 1561 |
+
$this->setFromEmailAddressLink($params['frm_addr_link']);
|
| 1562 |
+
$this->setReplyEmailAddress($params['rep_addr']);
|
| 1563 |
+
$this->setReplyEmailAddressLink($params['rep_addr_link']);
|
| 1564 |
+
|
| 1565 |
+
$this->setArchiveStatus($params['archive_status']);
|
| 1566 |
+
$this->setArchiveUrl($params['archive_url']);
|
| 1567 |
+
|
| 1568 |
+
return $this;
|
| 1569 |
+
}
|
| 1570 |
+
|
| 1571 |
+
private $campaignName;
|
| 1572 |
+
private $id;
|
| 1573 |
+
private $link;
|
| 1574 |
+
private $status;
|
| 1575 |
+
private $campaignDate;
|
| 1576 |
+
private $lastEditDate;
|
| 1577 |
+
private $campaignSent;
|
| 1578 |
+
private $campaignOpens;
|
| 1579 |
+
private $campaignClicks;
|
| 1580 |
+
private $campaignBounces;
|
| 1581 |
+
private $campaignForwards;
|
| 1582 |
+
private $campaignOptOuts;
|
| 1583 |
+
private $campaignSpamReports;
|
| 1584 |
+
private $subject;
|
| 1585 |
+
private $fromName;
|
| 1586 |
+
private $campaignType;
|
| 1587 |
+
private $vawp;
|
| 1588 |
+
private $vawpLinkText;
|
| 1589 |
+
private $vawpText;
|
| 1590 |
+
private $permissionReminder;
|
| 1591 |
+
private $permissionReminderText;
|
| 1592 |
+
private $greetingSalutation;
|
| 1593 |
+
private $greetingName;
|
| 1594 |
+
private $greetingString;
|
| 1595 |
+
private $orgName;
|
| 1596 |
+
private $orgAddr1;
|
| 1597 |
+
private $orgAddr2;
|
| 1598 |
+
private $orgAddr3;
|
| 1599 |
+
private $orgCity;
|
| 1600 |
+
private $orgState;
|
| 1601 |
+
private $orgInternationalState;
|
| 1602 |
+
private $orgCountry;
|
| 1603 |
+
private $orgPostalCode;
|
| 1604 |
+
private $incForwardEmail;
|
| 1605 |
+
private $forwardEmailLinkText;
|
| 1606 |
+
private $incSubscribeLink;
|
| 1607 |
+
private $subscribeLinkText;
|
| 1608 |
+
private $emailContentFormat;
|
| 1609 |
+
private $emailContent;
|
| 1610 |
+
private $textVersionContent;
|
| 1611 |
+
private $styleSheet;
|
| 1612 |
+
private $lists = array();
|
| 1613 |
+
private $fromEmailAddress;
|
| 1614 |
+
private $fromEmailAddressLink;
|
| 1615 |
+
private $replyEmailAddress;
|
| 1616 |
+
private $replyEmailAddressLink;
|
| 1617 |
+
private $archiveStatus;
|
| 1618 |
+
private $archiveUrl;
|
| 1619 |
+
|
| 1620 |
+
public function setCampaignName( $value ) { $this->campaignName = $value; }
|
| 1621 |
+
public function getCampaignName() { return $this->campaignName; }
|
| 1622 |
+
|
| 1623 |
+
public function setStatus( $value ) { $this->status = $value; }
|
| 1624 |
+
public function getStatus() { return $this->status; }
|
| 1625 |
+
|
| 1626 |
+
public function setCampaignDate( $value ) { $this->campaignDate = $value; }
|
| 1627 |
+
public function getCampaignDate() { return $this->campaignDate; }
|
| 1628 |
+
|
| 1629 |
+
|
| 1630 |
+
public function setLink( $value ) { $this->link = $value; }
|
| 1631 |
+
public function getLink() { return $this->link; }
|
| 1632 |
+
|
| 1633 |
+
public function setId( $value ) { $this->id = $value; }
|
| 1634 |
+
public function getId() { return $this->id; }
|
| 1635 |
+
|
| 1636 |
+
public function setLastEditDate( $value ) { $this->lastEditDate = $value; }
|
| 1637 |
+
public function getLastEditDate() { return $this->lastEditDate; }
|
| 1638 |
+
|
| 1639 |
+
public function setCampaignSent( $value ) { $this->campaignSent = $value; }
|
| 1640 |
+
public function getCampaignSent() { return $this->campaignSent; }
|
| 1641 |
+
|
| 1642 |
+
public function setCampaignOpens( $value ) { $this->campaignOpens = $value; }
|
| 1643 |
+
public function getCampaignOpens() { return $this->campaignOpens; }
|
| 1644 |
+
|
| 1645 |
+
public function setCampaignClicks( $value ) { $this->campaignClicks = $value; }
|
| 1646 |
+
public function getCampaignClicks() { return $this->campaignClicks; }
|
| 1647 |
+
|
| 1648 |
+
public function setCampaignBounces( $value ) { $this->campaignBounces = $value; }
|
| 1649 |
+
public function getCampaignBounces() { return $this->campaignBounces; }
|
| 1650 |
+
|
| 1651 |
+
public function setCampaignForwards( $value ) { $this->campaignForwards = $value; }
|
| 1652 |
+
public function getCampaignForwards() { return $this->campaignForwards; }
|
| 1653 |
+
|
| 1654 |
+
public function setCampaignOptOuts( $value ) { $this->campaignOptOuts = $value; }
|
| 1655 |
+
public function getCampaignOptOuts() { return $this->campaignOptOuts; }
|
| 1656 |
+
|
| 1657 |
+
public function setCampaignSpamReports( $value ) { $this->campaignSpamReports = $value; }
|
| 1658 |
+
public function getCampaignSpamReports() { return $this->campaignSpamReports; }
|
| 1659 |
+
|
| 1660 |
+
public function setCampaignType( $value ) { $this->campaignType = $value; }
|
| 1661 |
+
public function getCampaignType() { return $this->campaignType; }
|
| 1662 |
+
|
| 1663 |
+
public function setSubject( $value ) { $this->subject = $value; }
|
| 1664 |
+
public function getSubject() { return $this->subject; }
|
| 1665 |
+
|
| 1666 |
+
public function setFromName( $value ) { $this->fromName = $value; }
|
| 1667 |
+
public function getFromName() { return $this->fromName; }
|
| 1668 |
+
|
| 1669 |
+
public function setVawp( $value ) { $this->vawp = $value; }
|
| 1670 |
+
public function getVawp() { return $this->vawp; }
|
| 1671 |
+
|
| 1672 |
+
public function setVawpLinkText( $value ) { $this->vawpLinkText = $value; }
|
| 1673 |
+
public function getVawpLinkText() { return $this->vawpLinkText; }
|
| 1674 |
+
|
| 1675 |
+
public function setVawpText( $value ) { $this->vawpText = $value; }
|
| 1676 |
+
public function getVawpText() { return $this->vawpText; }
|
| 1677 |
+
|
| 1678 |
+
public function setPermissionReminder( $value ) { $this->permissionReminder = $value; }
|
| 1679 |
+
public function getPermissionReminder() { return $this->permissionReminder; }
|
| 1680 |
+
|
| 1681 |
+
public function setPermissionReminderText( $value ) { $this->permissionReminderText = $value; }
|
| 1682 |
+
public function getPermissionReminderText() { return $this->permissionReminderText; }
|
| 1683 |
+
|
| 1684 |
+
public function setGreetingSalutation( $value ) { $this->greetingSalutation = $value; }
|
| 1685 |
+
public function getGreetingSalutation() { return $this->greetingSalutation; }
|
| 1686 |
+
|
| 1687 |
+
public function setGreetingName( $value ) { $this->greetingName = $value; }
|
| 1688 |
+
public function getGreetingName() { return $this->greetingName; }
|
| 1689 |
+
|
| 1690 |
+
public function setGreetingString( $value ) { $this->greetingString = $value; }
|
| 1691 |
+
public function getGreetingString() { return $this->greetingString; }
|
| 1692 |
+
|
| 1693 |
+
public function setOrgName( $value ) { $this->orgName = $value; }
|
| 1694 |
+
public function getOrgName() { return $this->orgName; }
|
| 1695 |
+
|
| 1696 |
+
public function setOrgAddr1( $value ) { $this->orgAddr1 = $value; }
|
| 1697 |
+
public function getOrgAddr1() { return $this->orgAddr1; }
|
| 1698 |
+
|
| 1699 |
+
public function setOrgAddr2( $value ) { $this->orgAddr2 = $value; }
|
| 1700 |
+
public function getOrgAddr2() { return $this->orgAddr2; }
|
| 1701 |
+
|
| 1702 |
+
public function setOrgAddr3( $value ) { $this->orgAddr3 = $value; }
|
| 1703 |
+
public function getOrgAddr3() { return $this->orgAddr3; }
|
| 1704 |
+
|
| 1705 |
+
public function setOrgCity( $value ) { $this->orgCity = $value; }
|
| 1706 |
+
public function getOrgCity() { return $this->orgCity; }
|
| 1707 |
+
|
| 1708 |
+
public function setOrgState( $value ) { $this->orgState = $value; }
|
| 1709 |
+
public function getOrgState() { return $this->orgState; }
|
| 1710 |
+
|
| 1711 |
+
public function setOrgInternationalState( $value ) { $this->orgInternationalState = $value; }
|
| 1712 |
+
public function getOrgInternationalState() { return $this->orgInternationalState; }
|
| 1713 |
+
|
| 1714 |
+
public function setOrgCountry( $value ) { $this->orgCountry = $value; }
|
| 1715 |
+
public function getOrgCountry() { return $this->orgCountry; }
|
| 1716 |
+
|
| 1717 |
+
public function setOrgPostalCode( $value ) { $this->orgPostalCode = $value; }
|
| 1718 |
+
public function getOrgPostalCode() { return $this->orgPostalCode; }
|
| 1719 |
+
|
| 1720 |
+
public function setIncForwardEmail( $value ) { $this->incForwardEmail = $value; }
|
| 1721 |
+
public function getIncForwardEmail() { return $this->incForwardEmail; }
|
| 1722 |
+
|
| 1723 |
+
public function setForwardEmailLinkText( $value ) { $this->forwardEmailLinkText = $value; }
|
| 1724 |
+
public function getForwardEmailLinkText() { return $this->forwardEmailLinkText; }
|
| 1725 |
+
|
| 1726 |
+
public function setIncSubscribeLink( $value ) { $this->incSubscribeLink = $value; }
|
| 1727 |
+
public function getIncSubscribeLink() { return $this->incSubscribeLink; }
|
| 1728 |
+
|
| 1729 |
+
public function setSubscribeLinkText( $value ) { $this->subscribeLinkText = $value; }
|
| 1730 |
+
public function getSubscribeLinkText() { return $this->subscribeLinkText; }
|
| 1731 |
+
|
| 1732 |
+
public function setEmailContentFormat( $value ) { $this->emailContentFormat = $value; }
|
| 1733 |
+
public function getEmailContentFormat() { return $this->emailContentFormat; }
|
| 1734 |
+
|
| 1735 |
+
public function setEmailContent( $value ) { $this->emailContent = $value; }
|
| 1736 |
+
public function getEmailContent() { return $this->emailContent; }
|
| 1737 |
+
|
| 1738 |
+
public function setTextVersionContent( $value ) { $this->textVersionContent = $value; }
|
| 1739 |
+
public function getTextVersionContent() { return $this->textVersionContent; }
|
| 1740 |
+
|
| 1741 |
+
public function setStyleSheet( $value ) { $this->styleSheet = $value; }
|
| 1742 |
+
public function getStyleSheet() { return $this->styleSheet; }
|
| 1743 |
+
|
| 1744 |
+
public function setLists( $value ) { $this->lists[] = $value; }
|
| 1745 |
+
public function getLists() { return $this->lists; }
|
| 1746 |
+
public function removeLists() { $this->lists=""; }
|
| 1747 |
+
|
| 1748 |
+
public function setFromEmailAddress( $value ) { $this->fromEmailAddress = $value; }
|
| 1749 |
+
public function getFromEmailAddress() { return $this->fromEmailAddress; }
|
| 1750 |
+
|
| 1751 |
+
public function setFromEmailAddressLink( $value ) { $this->fromEmailAddressLink = $value; }
|
| 1752 |
+
public function getFromEmailAddressLink() { return $this->fromEmailAddressLink; }
|
| 1753 |
+
|
| 1754 |
+
public function setReplyEmailAddress( $value ) { $this->replyEmailAddress = $value; }
|
| 1755 |
+
public function getReplyEmailAddress() { return $this->replyEmailAddress; }
|
| 1756 |
+
|
| 1757 |
+
public function setReplyEmailAddressLink( $value ) { $this->replyEmailAddressLink = $value; }
|
| 1758 |
+
public function getReplyEmailAddressLink() { return $this->replyEmailAddressLink; }
|
| 1759 |
+
|
| 1760 |
+
public function setArchiveStatus( $value ) { $this->archiveStatus = $value; }
|
| 1761 |
+
public function getArchiveStatus() { return $this->archiveStatus; }
|
| 1762 |
+
|
| 1763 |
+
public function setArchiveUrl( $value ) { $this->archiveUrl = $value; }
|
| 1764 |
+
public function getArchiveUrl() { return $this->archiveUrl; }
|
| 1765 |
+
}
|
| 1766 |
+
/**
|
| 1767 |
+
* Campaigns Collection Class for calls to the campaign collection API
|
| 1768 |
+
*
|
| 1769 |
+
* Includes functions for listing all campaigns within the account, specific campaign details,
|
| 1770 |
+
* also creating and deleting campaigns
|
| 1771 |
+
*
|
| 1772 |
+
*/
|
| 1773 |
+
class CampaignsCollection
|
| 1774 |
+
{
|
| 1775 |
+
/**
|
| 1776 |
+
* Public function that does a POST to the Campaigns collection, passing a campaign object
|
| 1777 |
+
*
|
| 1778 |
+
* @param object $campaign - a valid campaign object with all required fields
|
| 1779 |
+
* @return string $code - returns success or fail code from API server
|
| 1780 |
+
*/
|
| 1781 |
+
public function createCampaign($campaign)
|
| 1782 |
+
{
|
| 1783 |
+
$utility = new Utility();
|
| 1784 |
+
$call = $utility->getApiPath() . '/ws/customers/'. $utility->getLogin() .'/campaigns';
|
| 1785 |
+
$campaignXml = $this->createCampaignXml(null, $campaign);
|
| 1786 |
+
$return = $utility->httpPost($call, $campaignXml);
|
| 1787 |
+
$code = $return['info']['http_code'];
|
| 1788 |
+
return $code;
|
| 1789 |
+
}
|
| 1790 |
+
/**
|
| 1791 |
+
* Public function that deletes a campaign, using a campaign object
|
| 1792 |
+
*
|
| 1793 |
+
* @param object $campaign - a valid campaign object with a valid campaign link
|
| 1794 |
+
* @return string $code - returns success or fail code from API server
|
| 1795 |
+
*/
|
| 1796 |
+
public function deleteCampaign($campaign)
|
| 1797 |
+
{
|
| 1798 |
+
$utility = new Utility();
|
| 1799 |
+
$call = $utility->getApiPath() . $campaign->getLink();
|
| 1800 |
+
$return = $utility->httpDelete($call);
|
| 1801 |
+
$code = $return['info']['http_code'];
|
| 1802 |
+
return $code;
|
| 1803 |
+
}
|
| 1804 |
+
/**
|
| 1805 |
+
* Public function that gets campaign details of a single campaign object passed to it.
|
| 1806 |
+
*
|
| 1807 |
+
* @param object $campaign - a valid campaign object with a valid campaign link
|
| 1808 |
+
* @return object $campaign - returns campaign object with full details
|
| 1809 |
+
*/
|
| 1810 |
+
public function listCampaignDetails($campaignObj)
|
| 1811 |
+
{
|
| 1812 |
+
$utility = new Utility();
|
| 1813 |
+
$call = $utility->getApiPath() . $campaignObj->getLink();
|
| 1814 |
+
$return = $utility->httpGet($call);
|
| 1815 |
+
$campaign = $this->createCampaignStruct($return['xml']);
|
| 1816 |
+
if (!$return)
|
| 1817 |
+
{
|
| 1818 |
+
return false;
|
| 1819 |
+
}
|
| 1820 |
+
else
|
| 1821 |
+
{
|
| 1822 |
+
return $campaign;
|
| 1823 |
+
}
|
| 1824 |
+
}
|
| 1825 |
+
/**
|
| 1826 |
+
* Public function that gets a list of first 50 campaigns in the account
|
| 1827 |
+
*
|
| 1828 |
+
* @return array $allCampaigns - an array of two arrays, array 1 is campaign objects, array 2 is link for next 50 campaigns
|
| 1829 |
+
*/
|
| 1830 |
+
public function listCampaigns()
|
| 1831 |
+
{
|
| 1832 |
+
$utility = new Utility();
|
| 1833 |
+
$return = $utility->httpGet($utility->getApiPath() . '/ws/customers/'. $utility->getLogin() .'/campaigns');
|
| 1834 |
+
|
| 1835 |
+
$allCampaigns = array();
|
| 1836 |
+
$campaignList = array();
|
| 1837 |
+
$pages = array();
|
| 1838 |
+
|
| 1839 |
+
$parsedReturn = simplexml_load_string($return['xml']);
|
| 1840 |
+
|
| 1841 |
+
foreach ($parsedReturn->entry as $item)
|
| 1842 |
+
{
|
| 1843 |
+
$campaign = new Campaign();
|
| 1844 |
+
$campaign->setLink($item->link['href']);
|
| 1845 |
+
$campaign->setId($item->id);
|
| 1846 |
+
$campaign->setCampaignName($item->content->Campaign->Name);
|
| 1847 |
+
$campaign->setStatus($item->content->Campaign->Status);
|
| 1848 |
+
$campaign->setCampaignDate($item->content->Campaign->Date);
|
| 1849 |
+
$campaignList[] = $campaign;
|
| 1850 |
+
}
|
| 1851 |
+
|
| 1852 |
+
if ($parsedReturn->link[4])
|
| 1853 |
+
{
|
| 1854 |
+
$pages[] = $parsedReturn->link[4]->Attributes()->href;
|
| 1855 |
+
}
|
| 1856 |
+
|
| 1857 |
+
$allCampaigns = array($campaignList, $pages);
|
| 1858 |
+
|
| 1859 |
+
return $allCampaigns;
|
| 1860 |
+
}
|
| 1861 |
+
/**
|
| 1862 |
+
* Public function that searches Campaigns by Status
|
| 1863 |
+
*
|
| 1864 |
+
* @param string $status - valid status is DRAFT, SENT, RUNNING, SCHEDULED
|
| 1865 |
+
* @return array $searchCampaigns - an array of two arrays, array 1 is search results, array 2 is link for next 50 search results
|
| 1866 |
+
*/
|
| 1867 |
+
public function searchCampaigns($status)
|
| 1868 |
+
{
|
| 1869 |
+
$utility = new Utility();
|
| 1870 |
+
$return = $utility->httpGet($utility->getApiPath() . '/ws/customers/'. $utility->getLogin() .'/campaigns?status=' . $status);
|
| 1871 |
+
$parsedReturn = simplexml_load_string($return['xml']);
|
| 1872 |
+
|
| 1873 |
+
$email = $parsedReturn->entry->content->Campaign;
|
| 1874 |
+
|
| 1875 |
+
if (!$email)
|
| 1876 |
+
{
|
| 1877 |
+
return false;
|
| 1878 |
+
}
|
| 1879 |
+
else
|
| 1880 |
+
{
|
| 1881 |
+
$searchResults = array();
|
| 1882 |
+
$pages = array();
|
| 1883 |
+
$searchCampaigns = array();
|
| 1884 |
+
|
| 1885 |
+
foreach ($parsedReturn->entry as $item)
|
| 1886 |
+
{
|
| 1887 |
+
$campaign = new Campaign();
|
| 1888 |
+
$campaign->setLink($item->link['href']);
|
| 1889 |
+
$campaign->setId($item->id);
|
| 1890 |
+
$campaign->setCampaignName($item->content->Campaign->Name);
|
| 1891 |
+
$campaign->setStatus($item->content->Campaign->Status);
|
| 1892 |
+
$campaign->setCampaignDate($item->content->Campaign->Date);
|
| 1893 |
+
$searchResults[] = $campaign;
|
| 1894 |
+
}
|
| 1895 |
+
|
| 1896 |
+
if ($parsedReturn->link[4])
|
| 1897 |
+
{
|
| 1898 |
+
$pages[] = $parsedReturn->link[4]->Attributes()->href;
|
| 1899 |
+
}
|
| 1900 |
+
|
| 1901 |
+
$searchCampaigns = array($searchResults, $pages);
|
| 1902 |
+
|
| 1903 |
+
return $searchCampaigns;
|
| 1904 |
+
}
|
| 1905 |
+
}
|
| 1906 |
+
/**
|
| 1907 |
+
* Public function that updates a draft campaign
|
| 1908 |
+
*
|
| 1909 |
+
* @param string $campaignId - valid campaign ID of the campaign that needs to be updated
|
| 1910 |
+
* @param object $campaign - valid campaign object of the new updates to the campaign
|
| 1911 |
+
* @return string $code - success or fail message from the API server
|
| 1912 |
+
*/
|
| 1913 |
+
public function updateCampaign($campaignId, $campaign)
|
| 1914 |
+
{
|
| 1915 |
+
$utility = new Utility();
|
| 1916 |
+
$existingCampaign = $this->getCampaignDetails($campaignId);
|
| 1917 |
+
$campaignXml = $this->createCampaignXml($existingCampaign->getId(), $campaign);
|
| 1918 |
+
$return = $utility->httpPut($utility->getApiPath() . $existingCampaign->getLink(), $campaignXml);
|
| 1919 |
+
$code = $return['info']['http_code'];
|
| 1920 |
+
return $code;
|
| 1921 |
+
}
|
| 1922 |
+
/**
|
| 1923 |
+
* Private function that creates a campaign object from XML
|
| 1924 |
+
*
|
| 1925 |
+
* @param string $campaignXml - Valid campaign XML
|
| 1926 |
+
* @return object $campaignStruct - returns a valid campaign object
|
| 1927 |
+
*/
|
| 1928 |
+
private function createCampaignStruct($campaignXml)
|
| 1929 |
+
{
|
| 1930 |
+
$campaign = array();
|
| 1931 |
+
$parsedReturn = simplexml_load_string($campaignXml);
|
| 1932 |
+
$campaign['link'] = ($parsedReturn->link->Attributes()->href);
|
| 1933 |
+
$campaign['id'] = ($parsedReturn->id);
|
| 1934 |
+
$campaign['campaign_name'] = ($parsedReturn->content->Campaign->Name);
|
| 1935 |
+
$campaign['status'] = ($parsedReturn->content->Campaign->Status);
|
| 1936 |
+
$campaign['campaign_date'] = ($parsedReturn->content->Campaign->Date);
|
| 1937 |
+
$campaign['last_edit_date'] = ($parsedReturn->content->Campaign->LastEditDate);
|
| 1938 |
+
$campaign['campaign_sent'] = ($parsedReturn->content->Campaign->Sent);
|
| 1939 |
+
$campaign['campaign_opens'] = ($parsedReturn->content->Campaign->Opens);
|
| 1940 |
+
$campaign['campaign_clicks'] = ($parsedReturn->content->Campaign->Clicks);
|
| 1941 |
+
$campaign['campaign_bounces'] = ($parsedReturn->content->Campaign->Bounces);
|
| 1942 |
+
$campaign['campaign_forwards'] = ($parsedReturn->content->Campaign->Forwards);
|
| 1943 |
+
$campaign['campaign_optouts'] = ($parsedReturn->content->Campaign->OptOuts);
|
| 1944 |
+
$campaign['campaign_spamreports'] = ($parsedReturn->content->Campaign->SpamReports);
|
| 1945 |
+
$campaign['subject'] = ($parsedReturn->content->Campaign->Subject);
|
| 1946 |
+
$campaign['from_name'] = ($parsedReturn->content->Campaign->FromName);
|
| 1947 |
+
$campaign['campaign_type'] = ($parsedReturn->content->Campaign->CampaignType);
|
| 1948 |
+
$campaign['view_as_web_page'] = ($parsedReturn->content->Campaign->ViewAsWebPage);
|
| 1949 |
+
$campaign['vawp_link_text'] = ($parsedReturn->content->Campaign->ViewAsWebPageLinkText);
|
| 1950 |
+
$campaign['vawp_text'] = ($parsedReturn->content->Campaign->ViewAsWebPageText);
|
| 1951 |
+
$campaign['permission_reminder'] = ($parsedReturn->content->Campaign->PermissionReminder);
|
| 1952 |
+
$campaign['permission_reminder_txt'] = ($parsedReturn->content->Campaign->PermissionReminderText);
|
| 1953 |
+
$campaign['greeting_salutation'] = ($parsedReturn->content->Campaign->GreetingSalutation);
|
| 1954 |
+
$campaign['greeting_name'] = ($parsedReturn->content->Campaign->GreetingName);
|
| 1955 |
+
$campaign['greeting_string'] = ($parsedReturn->content->Campaign->GreetingString);
|
| 1956 |
+
$campaign['org_name'] = ($parsedReturn->content->Campaign->OrganizationName);
|
| 1957 |
+
$campaign['org_address_1'] = ($parsedReturn->content->Campaign->OrganizationAddress1);
|
| 1958 |
+
$campaign['org_address_2'] = ($parsedReturn->content->Campaign->OrganizationAddress2);
|
| 1959 |
+
$campaign['org_address_3'] = ($parsedReturn->content->Campaign->OrganizationAddress3);
|
| 1960 |
+
$campaign['org_city'] = ($parsedReturn->content->Campaign->OrganizationCity);
|
| 1961 |
+
$campaign['org_state'] = ($parsedReturn->content->Campaign->OrganizationState);
|
| 1962 |
+
$campaign['org_international_state'] = ($parsedReturn->content->Campaign->OrganizationInternationalState);
|
| 1963 |
+
$campaign['org_country'] = ($parsedReturn->content->Campaign->OrganizationCountry);
|
| 1964 |
+
$campaign['org_postal_code'] = ($parsedReturn->content->Campaign->OrganizationPostalCode);
|
| 1965 |
+
$campaign['include_forward_email'] = ($parsedReturn->content->Campaign->IncludeForwardEmail);
|
| 1966 |
+
$campaign['forward_email_link_text'] = ($parsedReturn->content->Campaign->ForwardEmailLinkText);
|
| 1967 |
+
$campaign['include_subscribe_link'] = ($parsedReturn->content->Campaign->IncludeSubscribeLink);
|
| 1968 |
+
$campaign['subscribe_link_text'] = ($parsedReturn->content->Campaign->SubscribeLinkText);
|
| 1969 |
+
$campaign['email_content_format'] = ($parsedReturn->content->Campaign->EmailContentFormat);
|
| 1970 |
+
$campaign['email_content'] = ($parsedReturn->content->Campaign->EmailContent);
|
| 1971 |
+
$campaign['text_version_content'] = ($parsedReturn->content->Campaign->EmailTextContent);
|
| 1972 |
+
$campaign['style_sheet'] = ($parsedReturn->content->Campaign->StyleSheet);
|
| 1973 |
+
$campaign['archive_status'] = ($parsedReturn->content->Campaign->ArchiveStatus);
|
| 1974 |
+
$campaign['archive_url'] = ($parsedReturn->content->Campaign->ArchiveURL);
|
| 1975 |
+
$campaign['frm_addr'] = ($parsedReturn->content->Campaign->FromEmail->EmailAddress);
|
| 1976 |
+
$campaign['frm_addr_link'] = ($parsedReturn->content->Campaign->FromEmail->Email->link->Attributes()->href);
|
| 1977 |
+
$campaign['rep_addr'] = ($parsedReturn->content->Campaign->ReplyToEmail->EmailAddress);
|
| 1978 |
+
$campaign['rep_addr_link'] = ($parsedReturn->content->Campaign->ReplyToEmail->Email->link->Attributes()->href);
|
| 1979 |
+
|
| 1980 |
+
if ($parsedReturn->content->Contact->ContactLists->ContactList)
|
| 1981 |
+
{
|
| 1982 |
+
foreach ($parsedReturn->content->ContactLists->ContactList as $item)
|
| 1983 |
+
{
|
| 1984 |
+
$campaign['lists'][] = (trim((string) $item->Attributes()->href));
|
| 1985 |
+
}
|
| 1986 |
+
}
|
| 1987 |
+
|
| 1988 |
+
$campaignStruct = new Campaign($campaign);
|
| 1989 |
+
return $campaignStruct;
|
| 1990 |
+
}
|
| 1991 |
+
/**
|
| 1992 |
+
* Private function that creates campaign XML
|
| 1993 |
+
*
|
| 1994 |
+
* @param string $id - optional valid campaign ID, used for updating a campaign
|
| 1995 |
+
* @param object $campaign - a valid campaign object with all required fields
|
| 1996 |
+
* @return string $XmlReturn - valid XML of a campaign
|
| 1997 |
+
*/
|
| 1998 |
+
private function createCampaignXml($id, $campaign)
|
| 1999 |
+
{
|
| 2000 |
+
$utility = new Utility();
|
| 2001 |
+
|
| 2002 |
+
if (empty($id))
|
| 2003 |
+
{
|
| 2004 |
+
$id = ('http://api.constantcontact.com/ws/customers/' . $utility->getLogin() . '/campaigns/1100546096289');
|
| 2005 |
+
$standard_id = ('http://api.constantcontact.com/ws/customers/' . $utility->getLogin().'/campaigns');
|
| 2006 |
+
}
|
| 2007 |
+
else
|
| 2008 |
+
{
|
| 2009 |
+
$standard_id = $id;
|
| 2010 |
+
}
|
| 2011 |
+
|
| 2012 |
+
$xml = simplexml_load_string("<?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom' />");
|
| 2013 |
+
$link = $xml->addChild("link");
|
| 2014 |
+
$link_href = $link->addAttribute('href', '/ws/customers/' . $utility->getLogin() . '/campaigns');
|
| 2015 |
+
$link_rel = $link->addAttribute('rel', 'edit');
|
| 2016 |
+
$xml->addChild("id", $standard_id);
|
| 2017 |
+
$title = $xml->addChild("title", $campaign->getCampaignName());
|
| 2018 |
+
$title->addAttribute("type", "text");
|
| 2019 |
+
$xml->addChild("updated", date("Y-m-d").'T'.date("H:i:s").'+01:00');
|
| 2020 |
+
$author = $xml->addChild("author");
|
| 2021 |
+
$author->addChild("name", "Constant Contact");
|
| 2022 |
+
$content = $xml->addChild("content");
|
| 2023 |
+
$content->addAttribute("type", "application/vnd.ctct+xml");
|
| 2024 |
+
$campaign_node = $content->addChild("Campaign");
|
| 2025 |
+
$campaign_node->addAttribute("xmlns", "http://ws.constantcontact.com/ns/1.0/");
|
| 2026 |
+
$campaign_node->addAttribute("id", $id);
|
| 2027 |
+
$campaign_node->addChild("Name", $campaign->getCampaignName());
|
| 2028 |
+
$campaign_node->addChild("Status", "draft");
|
| 2029 |
+
$campaign_node->addChild("Date", date("Y-m-d").'T'.date("H:i:s").'+01:00');
|
| 2030 |
+
$campaign_node->addChild("Subject", $campaign->getSubject());
|
| 2031 |
+
$campaign_node->addChild("FromName", $campaign->getFromName());
|
| 2032 |
+
$campaign_node->addChild("ViewAsWebpage", $campaign->getVawp());
|
| 2033 |
+
$campaign_node->addChild("ViewAsWebpageLinkText", $campaign->getVawpLinkText());
|
| 2034 |
+
$campaign_node->addChild("ViewAsWebpageText", $campaign->getVawpText());
|
| 2035 |
+
$campaign_node->addChild("PermissionReminder", $campaign->getPermissionReminder());
|
| 2036 |
+
$campaign_node->addChild("PermissionReminderText", $campaign->getPermissionReminderText());
|
| 2037 |
+
$campaign_node->addChild("GreetingSalutation", $campaign->getGreetingSalutation());
|
| 2038 |
+
$campaign_node->addChild("GreetingName", $campaign->getGreetingName());
|
| 2039 |
+
$campaign_node->addChild("GreetingString", $campaign->getGreetingString());
|
| 2040 |
+
$campaign_node->addChild("OrganizationName", $campaign->getOrgName());
|
| 2041 |
+
$campaign_node->addChild("OrganizationAddress1", $campaign->getOrgAddr1());
|
| 2042 |
+
$campaign_node->addChild("OrganizationAddress2", $campaign->getOrgAddr2());
|
| 2043 |
+
$campaign_node->addChild("OrganizationAddress3", $campaign->getOrgAddr3());
|
| 2044 |
+
$campaign_node->addChild("OrganizationCity", $campaign->getOrgCity());
|
| 2045 |
+
$campaign_node->addChild("OrganizationState", $campaign->getOrgState());
|
| 2046 |
+
$campaign_node->addChild("OrganizationInternationalState", $campaign->getOrgInternationalState());
|
| 2047 |
+
$campaign_node->addChild("OrganizationCountry", $campaign->getOrgCountry());
|
| 2048 |
+
$campaign_node->addChild("OrganizationPostalCode", $campaign->getOrgPostalCode());
|
| 2049 |
+
$campaign_node->addChild("IncludeForwardEmail", $campaign->getIncForwardEmail());
|
| 2050 |
+
$campaign_node->addChild("ForwardEmailLinkText", $campaign->getForwardEmailLinkText());
|
| 2051 |
+
$campaign_node->addChild("IncludeSubscribeLink", $campaign->getIncSubscribeLink());
|
| 2052 |
+
$campaign_node->addChild("SubscribeLinkText", $campaign->getSubscribeLinkText());
|
| 2053 |
+
$campaign_node->addChild("EmailContentFormat", $campaign->getEmailContentFormat());
|
| 2054 |
+
$campaign_node->addChild("EmailContent", $campaign->getEmailContent());
|
| 2055 |
+
$campaign_node->addChild("EmailTextContent", $campaign->getTextVersionContent());
|
| 2056 |
+
$campaign_node->addChild("StyleSheet", $campaign->getStyleSheet());
|
| 2057 |
+
$contactLists = $campaign_node->addChild("ContactLists");
|
| 2058 |
+
$campaignLists = array();
|
| 2059 |
+
$campaignLists = $campaign->getLists();
|
| 2060 |
+
if ($campaignLists)
|
| 2061 |
+
{
|
| 2062 |
+
foreach ($campaignLists as $list)
|
| 2063 |
+
{
|
| 2064 |
+
$contactList = $contactLists->addChild("ContactList");
|
| 2065 |
+
$contactList->addAttribute("id", $list);
|
| 2066 |
+
$contactLink = $contactList->addChild("link");
|
| 2067 |
+
$contactLink->addAttribute("xmlns", "http://www.w3.org/2005/Atom");
|
| 2068 |
+
$contactLink->addAttribute("href", str_replace("http://api.constantcontact.com", "", $list));
|
| 2069 |
+
$contactLink->addAttribute("rel", "self");
|
| 2070 |
+
}
|
| 2071 |
+
}
|
| 2072 |
+
$fromEmail = $campaign_node->addChild("FromEmail");
|
| 2073 |
+
$email_node = $fromEmail->addChild("Email");
|
| 2074 |
+
$email_node->addAttribute("id", "http://api.constantcontact.com" . $campaign->getFromEmailAddressLink());
|
| 2075 |
+
$email_link = $email_node->addChild("link");
|
| 2076 |
+
$email_link->addAttribute("xmlns", "http://www.w3.org/2005/Atom");
|
| 2077 |
+
$email_link->addAttribute("href", $campaign->getFromEmailAddressLink());
|
| 2078 |
+
$email_link->addAttribute("rel", "self");
|
| 2079 |
+
$fromEmail->addChild("EmailAddress", $campaign->getFromEmailAddress());
|
| 2080 |
+
$replyEmail = $campaign_node->addChild("ReplyToEmail");
|
| 2081 |
+
$replyEmailNode = $replyEmail->addChild("Email");
|
| 2082 |
+
$replyEmailNode->addAttribute("id", "http://api.constantcontact.com" . $campaign->getReplyEmailAddressLink());
|
| 2083 |
+
$replyEmailLink = $replyEmailNode->addChild("link");
|
| 2084 |
+
$replyEmailLink->addAttribute("xmlns", "http://www.w3.org/2005/Atom");
|
| 2085 |
+
$replyEmailLink->addAttribute("href", $campaign->getReplyEmailAddressLink());
|
| 2086 |
+
$replyEmailLink->addAttribute("rel", "self");
|
| 2087 |
+
$replyEmail->addChild("EmailAddress", $campaign->getReplyEmailAddress());
|
| 2088 |
+
$sourceNode = $xml->addChild("source");
|
| 2089 |
+
$sourceNode->addChild("id", $standard_id);
|
| 2090 |
+
$sourceTitle = $sourceNode->addChild("title", "Campaigns for customer: " . $utility->getLogin());
|
| 2091 |
+
$sourceTitle->addAttribute("type", "text");
|
| 2092 |
+
$sourceLink1 = $sourceNode->addChild("link");
|
| 2093 |
+
$sourceLink1->addAttribute("href", "campaigns");
|
| 2094 |
+
$sourceLink2 = $sourceNode->addChild("link");
|
| 2095 |
+
$sourceLink2->addAttribute("href", "campaigns");
|
| 2096 |
+
$sourceLink2->addAttribute("rel", "self");
|
| 2097 |
+
$sourceAuthor = $sourceNode->addChild("author");
|
| 2098 |
+
$sourceAuthor->addChild("name", $utility->getLogin());
|
| 2099 |
+
$sourceNode->addChild("updated", date("Y-m-d").'T'.date("H:i:s").'+01:00');
|
| 2100 |
+
$xmlReturn = $xml->asXML();
|
| 2101 |
+
|
| 2102 |
+
return $xmlReturn;
|
| 2103 |
+
}
|
| 2104 |
+
}
|
| 2105 |
+
/**
|
| 2106 |
+
* ListObj class defines a list object
|
| 2107 |
+
*
|
| 2108 |
+
* Defines a list object, includes all campaign variables as well as the
|
| 2109 |
+
* getters and setters for variables
|
| 2110 |
+
*
|
| 2111 |
+
*/
|
| 2112 |
+
class ListObj
|
| 2113 |
+
{
|
| 2114 |
+
/**
|
| 2115 |
+
* Construct function for the List Class
|
| 2116 |
+
*
|
| 2117 |
+
* @param array $params - an array of variables that set up a list object
|
| 2118 |
+
* @return object list object with passed variables set to the object
|
| 2119 |
+
*/
|
| 2120 |
+
public function __construct($params = array())
|
| 2121 |
+
{
|
| 2122 |
+
$this->setContactCount($params['contact_count']);
|
| 2123 |
+
$this->setDisplayOnSignup($params['display_on_signup']);
|
| 2124 |
+
$this->setId($params['id']);
|
| 2125 |
+
$this->setLink($params['link']);
|
| 2126 |
+
$this->setName($params['list_name']);
|
| 2127 |
+
$this->setOptInDefault($params['opt_in_default']);
|
| 2128 |
+
$this->setSortOrder($params['sort_order']);
|
| 2129 |
+
$this->setUpdated($params['updated']);
|
| 2130 |
+
}
|
| 2131 |
+
|
| 2132 |
+
private $contactCount;
|
| 2133 |
+
private $displayOnSignup;
|
| 2134 |
+
private $id;
|
| 2135 |
+
private $link;
|
| 2136 |
+
private $name;
|
| 2137 |
+
private $optInDefault;
|
| 2138 |
+
private $sortOrder;
|
| 2139 |
+
private $updated;
|
| 2140 |
+
|
| 2141 |
+
public function setContactCount( $value ) { $this->contactCount = $value; }
|
| 2142 |
+
public function getContactCount() { return $this->contactCount; }
|
| 2143 |
+
|
| 2144 |
+
public function setDisplayOnSignup( $value ) { $this->displayOnSignup = $value; }
|
| 2145 |
+
public function getDisplayOnSignup() { return $this->displayOnSignup; }
|
| 2146 |
+
|
| 2147 |
+
public function setId( $value ) { $this->id = $value; }
|
| 2148 |
+
public function getId() { return $this->id; }
|
| 2149 |
+
|
| 2150 |
+
public function setLink( $value ) { $this->link = $value; }
|
| 2151 |
+
public function getLink() { return $this->link; }
|
| 2152 |
+
|
| 2153 |
+
public function setName( $value ) { $this->name = $value; }
|
| 2154 |
+
public function getName() { return $this->name; }
|
| 2155 |
+
|
| 2156 |
+
public function setOptInDefault( $value ) { $this->optInDefault = $value; }
|
| 2157 |
+
public function getOptInDefault() { return $this->optInDefault; }
|
| 2158 |
+
|
| 2159 |
+
public function setSortOrder( $value ) { $this->sortOrder = $value; }
|
| 2160 |
+
public function getSortOrder() { return $this->sortOrder; }
|
| 2161 |
+
|
| 2162 |
+
public function setUpdated( $value ) { $this->updated = $value; }
|
| 2163 |
+
public function getUpdated() { return $this->updated; }
|
| 2164 |
+
}
|
| 2165 |
+
/**
|
| 2166 |
+
* List Collection Class for calls to the list collection API
|
| 2167 |
+
*
|
| 2168 |
+
* Includes functions for listing lists, creating lists, and listing members in a list
|
| 2169 |
+
*
|
| 2170 |
+
*/
|
| 2171 |
+
class ListsCollection
|
| 2172 |
+
{
|
| 2173 |
+
/**
|
| 2174 |
+
* Public function that does a POST to the Lists collection, passing a list object
|
| 2175 |
+
*
|
| 2176 |
+
* @param object $list - a valid list object with all required fields
|
| 2177 |
+
* @return string $code - returns success or fail code from API server
|
| 2178 |
+
*/
|
| 2179 |
+
public function createList($list)
|
| 2180 |
+
{
|
| 2181 |
+
$utility = new Utility();
|
| 2182 |
+
$call = $utility->getApiPath() . '/ws/customers/'. $utility->getLogin() .'/lists';
|
| 2183 |
+
$listStruct = $this->createListXml(null, $list);
|
| 2184 |
+
$return = $utility->httpPost($call, $listStruct);
|
| 2185 |
+
$code = $return['info']['http_code'];
|
| 2186 |
+
return $code;
|
| 2187 |
+
}
|
| 2188 |
+
|
| 2189 |
+
/**
|
| 2190 |
+
* Public function that deletes a list from the account
|
| 2191 |
+
*
|
| 2192 |
+
* @param object $list - a valid list object with a valid lists link
|
| 2193 |
+
* @return string $code - returns success or fail code from API server
|
| 2194 |
+
*/
|
| 2195 |
+
public function deleteList($list)
|
| 2196 |
+
{
|
| 2197 |
+
$utility = new Utility();
|
| 2198 |
+
$call = $utility->getApiPath() . $list->getLink();
|
| 2199 |
+
$return = $utility->httpDelete($call);
|
| 2200 |
+
$code = $return['info']['http_code'];
|
| 2201 |
+
return code;
|
| 2202 |
+
}
|
| 2203 |
+
|
| 2204 |
+
/**
|
| 2205 |
+
* Public function that gets list details of a single list object passed to it.
|
| 2206 |
+
*
|
| 2207 |
+
* @param object $list - a valid list object with a valid list link
|
| 2208 |
+
* @return object $list - returns list object with full details
|
| 2209 |
+
*/
|
| 2210 |
+
public function getListDetails($list)
|
| 2211 |
+
{
|
| 2212 |
+
$utility = new Utility();
|
| 2213 |
+
$call = $utility->getApiPath() . $list->getLink();
|
| 2214 |
+
$return = $utility->httpGet($call);
|
| 2215 |
+
$list = $this->createListStruct($return['xml']);
|
| 2216 |
+
if (!$return)
|
| 2217 |
+
{
|
| 2218 |
+
return false;
|
| 2219 |
+
}
|
| 2220 |
+
else
|
| 2221 |
+
{
|
| 2222 |
+
return $list;
|
| 2223 |
+
}
|
| 2224 |
+
}
|
| 2225 |
+
/**
|
| 2226 |
+
* Public function that gets list members of a single list object passed to it.
|
| 2227 |
+
*
|
| 2228 |
+
* @param object $list - a valid list object with a valid list link
|
| 2229 |
+
* @return array $List - returns first 50 contact objects that are part of that list, and a link to next 50
|
| 2230 |
+
*/
|
| 2231 |
+
public function getListMembers($list)
|
| 2232 |
+
{
|
| 2233 |
+
$utility = new Utility();
|
| 2234 |
+
$call = $utility->getApiPath() . $list->getLink() . '/members';
|
| 2235 |
+
$return = $utility->httpGet($call);
|
| 2236 |
+
$parsedReturn = simplexml_load_string($return['xml']);
|
| 2237 |
+
|
| 2238 |
+
|
| 2239 |
+
$List = array();
|
| 2240 |
+
|
| 2241 |
+
$listMembers = array();
|
| 2242 |
+
$pages = array();
|
| 2243 |
+
|
| 2244 |
+
foreach ($parsedReturn->entry as $item)
|
| 2245 |
+
{
|
| 2246 |
+
$contact = new Contact();
|
| 2247 |
+
$contact->setLink($item->link->Attributes()->href);
|
| 2248 |
+
$contact->setId($item->id);
|
| 2249 |
+
$contact->setFullName($item->content->ContactListMember->Name);
|
| 2250 |
+
$contact->setEmailAddress($item->content->ContactListMember->EmailAddress);
|
| 2251 |
+
$listMembers[] = $contact;
|
| 2252 |
+
}
|
| 2253 |
+
|
| 2254 |
+
$pages[] = $parsedReturn->link[2]->Attributes();
|
| 2255 |
+
$pages[] = $parsedReturn->link[3]->Attributes();
|
| 2256 |
+
//$pages[] = $parsedReturn->link[4]->Attributes();
|
| 2257 |
+
|
| 2258 |
+
$List = array($listMembers, $pages);
|
| 2259 |
+
|
| 2260 |
+
if (!$return)
|
| 2261 |
+
{
|
| 2262 |
+
return false;
|
| 2263 |
+
}
|
| 2264 |
+
else
|
| 2265 |
+
{
|
| 2266 |
+
return $List;
|
| 2267 |
+
}
|
| 2268 |
+
}
|
| 2269 |
+
/**
|
| 2270 |
+
* Public function that gets a list of first 50 lists in the account
|
| 2271 |
+
*
|
| 2272 |
+
* @return array $allLists - an array of two arrays, array 1 is list objects, array 2 is link for next 50 lists
|
| 2273 |
+
*/
|
| 2274 |
+
public function getLists()
|
| 2275 |
+
{
|
| 2276 |
+
$utility = new Utility();
|
| 2277 |
+
$return = $utility->httpGet($utility->getApiPath() . '/ws/customers/'. $utility->getLogin() .'/lists');
|
| 2278 |
+
$allLists = array();
|
| 2279 |
+
|
| 2280 |
+
$Lists = array();
|
| 2281 |
+
$pages = array();
|
| 2282 |
+
|
| 2283 |
+
$parsedReturn = simplexml_load_string($return['xml']);
|
| 2284 |
+
$listArray = array();
|
| 2285 |
+
|
| 2286 |
+
foreach ($parsedReturn->entry as $item)
|
| 2287 |
+
{
|
| 2288 |
+
$listArray['link'] = ($item->link->Attributes()->href);
|
| 2289 |
+
$listArray['id'] = ($item->id);
|
| 2290 |
+
$listArray['opt_in_default'] = ($item->content->ContactList->OptInDefault);
|
| 2291 |
+
$listArray['list_name'] = ($item->content->ContactList->Name);
|
| 2292 |
+
$listArray['display_on_signup'] = ($item->content->ContactList->DisplayOnSignup);
|
| 2293 |
+
$listArray['sort_order'] = ($item->content->ContactList->SortOrder);
|
| 2294 |
+
$listArray['contact_count'] = ($item->content->ContactList->ContactCount);
|
| 2295 |
+
$list = new ListObj($listArray);
|
| 2296 |
+
$Lists[] = $list;
|
| 2297 |
+
}
|
| 2298 |
+
|
| 2299 |
+
$pages[] = $parsedReturn->link[2]->Attributes();
|
| 2300 |
+
$pages[] = $parsedReturn->link[3]->Attributes();
|
| 2301 |
+
//$pages[] = $parsedReturn->link[4]->Attributes();
|
| 2302 |
+
|
| 2303 |
+
$allLists = array($Lists, $pages);
|
| 2304 |
+
|
| 2305 |
+
return $allLists;
|
| 2306 |
+
}
|
| 2307 |
+
/**
|
| 2308 |
+
* Public function that updates a list
|
| 2309 |
+
*
|
| 2310 |
+
* @param string $listId - valid list ID of the list that needs to be updated
|
| 2311 |
+
* @param object $list - valid list object of the new updates to the list
|
| 2312 |
+
* @return string $code - success or fail message from the API server
|
| 2313 |
+
*/
|
| 2314 |
+
public function updateList($listId, $list)
|
| 2315 |
+
{
|
| 2316 |
+
$utility = new Utility();
|
| 2317 |
+
$existingList = $this->getListDetails($listId);
|
| 2318 |
+
$listXml = $this->createListXml($existingList->getId(), $list);
|
| 2319 |
+
$return = $utility->httpPut($utility->getApiPath() . $existingList->getLink(), $listXml);
|
| 2320 |
+
$code = $return['info']['http_code'];
|
| 2321 |
+
return $code;
|
| 2322 |
+
}
|
| 2323 |
+
|
| 2324 |
+
/**
|
| 2325 |
+
* Private function that creates a list object from XML
|
| 2326 |
+
*
|
| 2327 |
+
* @param string $listXml - Valid list XML
|
| 2328 |
+
* @return object $listStruct - returns a valid list object
|
| 2329 |
+
*/
|
| 2330 |
+
private function createListStruct($listXml)
|
| 2331 |
+
{
|
| 2332 |
+
$parsedReturn = simplexml_load_string($listXml);
|
| 2333 |
+
|
| 2334 |
+
$listArray['link'] = ($parsedReturn->link->Attributes()->href);
|
| 2335 |
+
$listArray['id'] = ($parsedReturn->id);
|
| 2336 |
+
$listArray['opt_in_default'] = ($parsedReturn->content->ContactList->OptInDefault);
|
| 2337 |
+
$listArray['list_name'] = ($parsedReturn->content->ContactList->Name);
|
| 2338 |
+
$listArray['display_on_signup'] = ($parsedReturn->content->ContactList->DisplayOnSignup);
|
| 2339 |
+
$listArray['sort_order'] = ($parsedReturn->content->ContactList->SortOrder);
|
| 2340 |
+
$listArray['contact_count'] = ($parsedReturn->content->ContactList->ContactCount);
|
| 2341 |
+
$list = new ListObj($listArray);
|
| 2342 |
+
return $list;
|
| 2343 |
+
}
|
| 2344 |
+
/**
|
| 2345 |
+
* Private function that creates list XML
|
| 2346 |
+
*
|
| 2347 |
+
* @param string $id - optional valid list ID, used for updating a list
|
| 2348 |
+
* @param object $list - valid list object
|
| 2349 |
+
* @return string $entry - valid XML of a list
|
| 2350 |
+
*/
|
| 2351 |
+
private function createListXml($id, $list)
|
| 2352 |
+
{
|
| 2353 |
+
$utility = new Utility();
|
| 2354 |
+
|
| 2355 |
+
if ( empty($id)) {
|
| 2356 |
+
$id = "urn:uuid:E8553C09F4xcvxCCC53F481214230867087";
|
| 2357 |
+
}
|
| 2358 |
+
|
| 2359 |
+
$update_date = date("Y-m-d").'T'.date("H:i:s").'+01:00';
|
| 2360 |
+
$xml_string = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><entry xmlns='http://www.w3.org/2005/Atom'></entry>";
|
| 2361 |
+
$xml_object = simplexml_load_string($xml_string);
|
| 2362 |
+
$title_node = $xml_object->addChild("title", htmlspecialchars(("TitleNode"), ENT_QUOTES, 'UTF-8'));
|
| 2363 |
+
$updated_node = $xml_object->addChild("updated", htmlspecialchars(($update_date), ENT_QUOTES, 'UTF-8'));
|
| 2364 |
+
$author_node = $xml_object->addChild("author");
|
| 2365 |
+
$author_name = $author_node->addChild("name", ("CTCT Samples"));
|
| 2366 |
+
$id_node = $xml_object->addChild("id", htmlspecialchars(((string) $id),ENT_QUOTES, 'UTF-8'));
|
| 2367 |
+
$summary_node = $xml_object->addChild("summary", htmlspecialchars(("Customer document"),ENT_QUOTES, 'UTF-8'));
|
| 2368 |
+
$summary_node->addAttribute("type", "text");
|
| 2369 |
+
$content_node = $xml_object->addChild("content");
|
| 2370 |
+
$content_node->addAttribute("type", "application/vnd.ctct+xml");
|
| 2371 |
+
$contact_node = $content_node->addChild("ContactList", htmlspecialchars(("Customer document"), ENT_QUOTES, 'UTF-8'));
|
| 2372 |
+
$contact_node->addAttribute("xmlns", "http://ws.constantcontact.com/ns/1.0/");
|
| 2373 |
+
$email_node = $contact_node->addChild("Name", htmlspecialchars(($list->getName()), ENT_QUOTES, 'UTF-8'));
|
| 2374 |
+
$email_node = $contact_node->addChild("SortOrder", htmlspecialchars(($list->getSortOrder()), ENT_QUOTES, 'UTF-8'));
|
| 2375 |
+
$email_node = $contact_node->addChild("OptInDefault", htmlspecialchars(($list->getOptInDefault()), ENT_QUOTES, 'UTF-8'));
|
| 2376 |
+
|
| 2377 |
+
$entry = $xml_object->asXML();
|
| 2378 |
+
return $entry;
|
| 2379 |
+
}
|
| 2380 |
+
}
|
| 2381 |
+
/**
|
| 2382 |
+
* VerifiedAddress class
|
| 2383 |
+
*
|
| 2384 |
+
* Defines a verified address object, includes all verified address variables as well as the
|
| 2385 |
+
* getters and setters for variables
|
| 2386 |
+
*
|
| 2387 |
+
*/
|
| 2388 |
+
class VerifiedAddress
|
| 2389 |
+
{
|
| 2390 |
+
/**
|
| 2391 |
+
* Construct function for the VerifiedAddress Class
|
| 2392 |
+
*
|
| 2393 |
+
* @param array $params - an array of variables that set up a verifiedaddress object
|
| 2394 |
+
* @return object verifiedaddress object with passed variables set to the object
|
| 2395 |
+
*/
|
| 2396 |
+
public function __construct($params = array())
|
| 2397 |
+
{
|
| 2398 |
+
$this->setLink($params['verified_email_link']);
|
| 2399 |
+
$this->setId($params['verified_email_id']);
|
| 2400 |
+
$this->setEmailAddress($params['verified_email_address']);
|
| 2401 |
+
$this->setStatus($params['verified_email_status']);
|
| 2402 |
+
$this->setVerifiedTime($params['verified_time']);
|
| 2403 |
+
|
| 2404 |
+
return $this;
|
| 2405 |
+
}
|
| 2406 |
+
|
| 2407 |
+
private $link;
|
| 2408 |
+
private $id;
|
| 2409 |
+
private $emailAddress;
|
| 2410 |
+
private $status;
|
| 2411 |
+
private $verifiedTime;
|
| 2412 |
+
|
| 2413 |
+
public function setLink( $value ) { $this->link = $value; }
|
| 2414 |
+
public function getLink() { $this->link; }
|
| 2415 |
+
|
| 2416 |
+
public function setId( $value ) { $this->id = $value; }
|
| 2417 |
+
public function getId() { $this->id; }
|
| 2418 |
+
|
| 2419 |
+
public function setEmailAddress( $value ) { $this->emailAddress = $value; }
|
| 2420 |
+
public function getEmailAddress() { $this->emailAddress; }
|
| 2421 |
+
|
| 2422 |
+
public function setStatus( $value ) { $this->status = $value; }
|
| 2423 |
+
public function getStatus() { $this->status; }
|
| 2424 |
+
|
| 2425 |
+
public function setVerifiedTime( $value ) { $this->verifiedTime = $value; }
|
| 2426 |
+
public function getVerifiedTime() { $this->verifiedTime; }
|
| 2427 |
+
}
|
| 2428 |
+
/**
|
| 2429 |
+
* Settings Collection Class for calls to the settings collection API
|
| 2430 |
+
*
|
| 2431 |
+
* Includes functions for listing all verified addresses in an account
|
| 2432 |
+
*
|
| 2433 |
+
*/
|
| 2434 |
+
class SettingsCollection
|
| 2435 |
+
{
|
| 2436 |
+
/**
|
| 2437 |
+
* Public function that gets a list of first 50 verified addresses in the account
|
| 2438 |
+
*
|
| 2439 |
+
* @return array $verifiedAddress - an array of two arrays, array 1 is verifiedaddress objects, array 2 is link for next 50 verified addresses
|
| 2440 |
+
*/
|
| 2441 |
+
public function listVerifiedAddresses()
|
| 2442 |
+
{
|
| 2443 |
+
$utility = new Utility();
|
| 2444 |
+
$return = $utility->httpGet($utility->getApiPath() . '/ws/customers/'. $utility->getLogin() .'/settings/emailaddresses');
|
| 2445 |
+
$allAddresses = array();
|
| 2446 |
+
|
| 2447 |
+
$addressList = array();
|
| 2448 |
+
$pages = array();
|
| 2449 |
+
|
| 2450 |
+
$parsedReturn = simplexml_load_string($return['xml']);
|
| 2451 |
+
|
| 2452 |
+
foreach ($parsedReturn->entry as $item)
|
| 2453 |
+
{
|
| 2454 |
+
$newAddress = $this->createVerifiedStruct($item);
|
| 2455 |
+
$addressList[] = $newAddress;
|
| 2456 |
+
}
|
| 2457 |
+
|
| 2458 |
+
if ($parsedReturn->link[2])
|
| 2459 |
+
{
|
| 2460 |
+
$pages[] = $parsedReturn->link[2]->Attributes()->href;
|
| 2461 |
+
}
|
| 2462 |
+
|
| 2463 |
+
$allAddresses = array($addressList, $pages);
|
| 2464 |
+
|
| 2465 |
+
return $allAddresses;
|
| 2466 |
+
}
|
| 2467 |
+
/**
|
| 2468 |
+
* Private function that creates a verifiedaddress object from XML
|
| 2469 |
+
*
|
| 2470 |
+
* @param string $parsedXml - Valid verifiedaddress XML
|
| 2471 |
+
* @return object $verifiedAddress - returns a valid verifiedAddress object
|
| 2472 |
+
*/
|
| 2473 |
+
private function createVerifiedStruct($parsedXml)
|
| 2474 |
+
{
|
| 2475 |
+
$verifiedArray = array();
|
| 2476 |
+
$verifiedArray['verified_email_link'] = ($parsedXml->link->Attributes()->href);
|
| 2477 |
+
$verifiedArray['verified_email_id'] = ($parsedXml->id);
|
| 2478 |
+
$verifiedArray['verified_email_address'] = ($parsedXml->content->Email->EmailAddress);
|
| 2479 |
+
$verifiedArray['verified_email_status'] = ($parsedXml->content->Email->Status);
|
| 2480 |
+
$verifiedArray['verified_time'] = ($parsedXml->content->Email->VerifiedTime);
|
| 2481 |
+
|
| 2482 |
+
$verifiedAddress = new VerifiedAddress($verifiedArray);
|
| 2483 |
+
return $verifiedAddress;
|
| 2484 |
+
}
|
| 2485 |
+
}
|
| 2486 |
+
/**
|
| 2487 |
+
* Event class defines an event object
|
| 2488 |
+
*
|
| 2489 |
+
* Defines an event object, includes all campaign variables as well as the
|
| 2490 |
+
* getters and setters for variables
|
| 2491 |
+
*
|
| 2492 |
+
*/
|
| 2493 |
+
class Event
|
| 2494 |
+
{
|
| 2495 |
+
/**
|
| 2496 |
+
* Construct function for the Event Class
|
| 2497 |
+
*
|
| 2498 |
+
* @param array $params - an array of variables that set up a event object
|
| 2499 |
+
* @return object event object with passed variables set to the object
|
| 2500 |
+
*/
|
| 2501 |
+
public function __construct($params = array())
|
| 2502 |
+
{
|
| 2503 |
+
$this->setLink($params['event_link']);
|
| 2504 |
+
$this->setName($params['event_name']);
|
| 2505 |
+
$this->setDescription($params['event_description']);
|
| 2506 |
+
$this->setTitle($params['event_title']);
|
| 2507 |
+
$this->setRegistered($params['registered']);
|
| 2508 |
+
$this->setCreatedDate($params['created_date']);
|
| 2509 |
+
$this->setStatus($params['event_status']);
|
| 2510 |
+
$this->setEventType($params['event_type']);
|
| 2511 |
+
$this->setLocation($params['location']);
|
| 2512 |
+
$this->setAddr1($params['event_addr1']);
|
| 2513 |
+
$this->setAddr2($params['event_addr2']);
|
| 2514 |
+
$this->setAddr3($params['event_addr3']);
|
| 2515 |
+
$this->setCity($params['event_city']);
|
| 2516 |
+
$this->setState($params['event_state']);
|
| 2517 |
+
$this->setCountry($params['event_country']);
|
| 2518 |
+
$this->setPostalCode($params['event_postalcode']);
|
| 2519 |
+
$this->setRegistrationUrl($params['registration_url']);
|
| 2520 |
+
$this->setStartDate($params['event_start']);
|
| 2521 |
+
$this->setEndDate($params['event_end']);
|
| 2522 |
+
$this->setPublishDate($params['event_publishdate']);
|
| 2523 |
+
$this->setWebPage($params['event_webpage']);
|
| 2524 |
+
$this->setAttendedCount($params['attended_count']);
|
| 2525 |
+
$this->setCancelledCount($params['cancelled_count']);
|
| 2526 |
+
$this->setEventFeeRequired($params['event_fee_required']);
|
| 2527 |
+
$this->setCurrencyType($params['currency_type']);
|
| 2528 |
+
$this->setRegistrationLimitDate($params['reg_limit_date']);
|
| 2529 |
+
$this->setRegistrationLimitCount($params['reg_limit_count']);
|
| 2530 |
+
$this->setRegistrationClosedManually($params['reg_closed_manually']);
|
| 2531 |
+
$this->setEarlyFeeDate($params['early_fee_date']);
|
| 2532 |
+
$this->setLateFeeDate($params['late_fee_date']);
|
| 2533 |
+
$this->setGuestLimit($params['guest_limit']);
|
| 2534 |
+
$this->setTicketing($params['ticketing']);
|
| 2535 |
+
|
| 2536 |
+
if ($params['payment_options'])
|
| 2537 |
+
{
|
| 2538 |
+
foreach ($params['payment_options'] as $tmp)
|
| 2539 |
+
{
|
| 2540 |
+
$this->setPaymentOptions($tmp);
|
| 2541 |
+
}
|
| 2542 |
+
}
|
| 2543 |
+
|
| 2544 |
+
if ($params['event_fees'])
|
| 2545 |
+
{
|
| 2546 |
+
foreach ($params['event_fees'] as $tmp)
|
| 2547 |
+
{
|
| 2548 |
+
$this->setEventFee($tmp);
|
| 2549 |
+
}
|
| 2550 |
+
}
|
| 2551 |
+
|
| 2552 |
+
return $this;
|
| 2553 |
+
}
|
| 2554 |
+
|
| 2555 |
+
private $link;
|
| 2556 |
+
private $name;
|
| 2557 |
+
private $description;
|
| 2558 |
+
private $title;
|
| 2559 |
+
private $registered;
|
| 2560 |
+
private $createdDate;
|
| 2561 |
+
private $status;
|
| 2562 |
+
private $eventType;
|
| 2563 |
+
private $location;
|
| 2564 |
+
private $addr1;
|
| 2565 |
+
private $addr2;
|
| 2566 |
+
private $addr3;
|
| 2567 |
+
private $city;
|
| 2568 |
+
private $state;
|
| 2569 |
+
private $country;
|
| 2570 |
+
private $postalCode;
|
| 2571 |
+
private $regstrationUrl;
|
| 2572 |
+
private $startDate;
|
| 2573 |
+
private $EndDate;
|
| 2574 |
+
private $publishDate;
|
| 2575 |
+
private $webPage;
|
| 2576 |
+
private $attendedCount;
|
| 2577 |
+
private $cancelledCount;
|
| 2578 |
+
private $eventFeeRequired;
|
| 2579 |
+
private $currencyType;
|
| 2580 |
+
private $paymentOptions = array();
|
| 2581 |
+
private $registrationLimitDate;
|
| 2582 |
+
private $registrationLimitCount;
|
| 2583 |
+
private $registrationClosedManually;
|
| 2584 |
+
private $earlyFeeDate;
|
| 2585 |
+
private $lateFeeDate;
|
| 2586 |
+
private $guestLimit;
|
| 2587 |
+
private $ticketing;
|
| 2588 |
+
private $eventFee = array();
|
| 2589 |
+
|
| 2590 |
+
public function setLink( $value ) { $this->link = $value; }
|
| 2591 |
+
public function getLink() { return $this->link; }
|
| 2592 |
+
|
| 2593 |
+
public function setName( $value ) { $this->name = $value; }
|
| 2594 |
+
public function getName() { return $this->name; }
|
| 2595 |
+
|
| 2596 |
+
public function setDescription( $value ) { $this->description = $value; }
|
| 2597 |
+
public function getDescription() { return $this->description; }
|
| 2598 |
+
|
| 2599 |
+
public function setTitle( $value ) { $this->title = $value; }
|
| 2600 |
+
public function getTitle() { return $this->title; }
|
| 2601 |
+
|
| 2602 |
+
public function setRegistered( $value ) { $this->registered = $value; }
|
| 2603 |
+
public function getRegistered() { return $this->registered; }
|
| 2604 |
+
|
| 2605 |
+
public function setCreatedDate( $value ) { $this->createdDate = $value; }
|
| 2606 |
+
public function getCreatedDate() { return $this->createdDate; }
|
| 2607 |
+
|
| 2608 |
+
public function setStatus( $value ) { $this->status = $value; }
|
| 2609 |
+
public function getStatus() { return $this->status; }
|
| 2610 |
+
|
| 2611 |
+
public function setEventType( $value ) { $this->eventType = $value; }
|
| 2612 |
+
public function getEventType() { return $this->eventType; }
|
| 2613 |
+
|
| 2614 |
+
public function setLocation( $value ) { $this->location = $value; }
|
| 2615 |
+
public function getLocation() { return $this->location; }
|
| 2616 |
+
|
| 2617 |
+
public function setAddr1( $value ) { $this->addr1 = $value; }
|
| 2618 |
+
public function getAddr1() { return $this->addr1; }
|
| 2619 |
+
|
| 2620 |
+
public function setAddr2( $value ) { $this->addr2 = $value; }
|
| 2621 |
+
public function getAddr2() { return $this->addr2; }
|
| 2622 |
+
|
| 2623 |
+
public function setAddr3( $value ) { $this->addr3 = $value; }
|
| 2624 |
+
public function getAddr3() { return $this->addr3; }
|
| 2625 |
+
|
| 2626 |
+
public function setCity( $value ) { $this->city = $value; }
|
| 2627 |
+
public function getCity() { return $this->city; }
|
| 2628 |
+
|
| 2629 |
+
public function setState( $value ) { $this->state = $value; }
|
| 2630 |
+
public function getState() { return $this->state; }
|
| 2631 |
+
|
| 2632 |
+
public function setCountry( $value ) { $this->country = $value; }
|
| 2633 |
+
public function getCountry() { return $this->country; }
|
| 2634 |
+
|
| 2635 |
+
public function setPostalCode( $value ) { $this->postalCode = $value; }
|
| 2636 |
+
public function getPostalCode() { return $this->postalCode; }
|
| 2637 |
+
|
| 2638 |
+
public function setRegistrationUrl( $value ) { $this->regstrationUrl = $value; }
|
| 2639 |
+
public function getRegistrationUrl() { return $this->regstrationUrl; }
|
| 2640 |
+
|
| 2641 |
+
public function setStartDate( $value ) { $this->startDate = $value; }
|
| 2642 |
+
public function getStartDate() { return $this->startDate; }
|
| 2643 |
+
|
| 2644 |
+
public function setEndDate( $value ) { $this->EndDate = $value; }
|
| 2645 |
+
public function getEndDate() { return $this->EndDate; }
|
| 2646 |
+
|
| 2647 |
+
public function setPublishDate( $value ) { $this->publishDate = $value; }
|
| 2648 |
+
public function getPublishDate() { return $this->publishDate; }
|
| 2649 |
+
|
| 2650 |
+
public function setWebPage( $value ) { $this->webPage = $value; }
|
| 2651 |
+
public function getWebPage() { return $this->webPage; }
|
| 2652 |
+
|
| 2653 |
+
public function setAttendedCount( $value ) { $this->attendedCount = $value; }
|
| 2654 |
+
public function getAttendedCount() { return $this->attendedCount; }
|
| 2655 |
+
|
| 2656 |
+
public function setCancelledCount( $value ) { $this->cancelledCount = $value; }
|
| 2657 |
+
public function getCancelledCount() { return $this->cancelledCount; }
|
| 2658 |
+
|
| 2659 |
+
public function setEventFeeRequired( $value ) { $this->eventFeeRequired = $value; }
|
| 2660 |
+
public function getEventFeeRequired() { return $this->eventFeeRequired; }
|
| 2661 |
+
|
| 2662 |
+
public function setCurrencyType( $value ) { $this->currencyType = $value; }
|
| 2663 |
+
public function getCurrencyType() { return $this->currencyType; }
|
| 2664 |
+
|
| 2665 |
+
public function setPaymentOptions( $value ) { $this->paymentOptions[] = $value; }
|
| 2666 |
+
public function getPaymentOptions() { return $this->paymentOptions; }
|
| 2667 |
+
|
| 2668 |
+
public function setRegistrationLimitDate( $value ) { $this->registrationLimitDate = $value; }
|
| 2669 |
+
public function getRegistrationLimitDate() { return $this->registrationLimitDate; }
|
| 2670 |
+
|
| 2671 |
+
public function setRegistrationLimitCount( $value ) { $this->registrationLimitCount = $value; }
|
| 2672 |
+
public function getRegistrationLimitCount() { return $this->registrationLimitCount; }
|
| 2673 |
+
|
| 2674 |
+
public function setRegistrationClosedManually( $value ) { $this->registrationClosedManually = $value; }
|
| 2675 |
+
public function getRegistrationClosedManually() { return $this->registrationClosedManually; }
|
| 2676 |
+
|
| 2677 |
+
public function setEarlyFeeDate( $value ) { $this->earlyFeeDate = $value; }
|
| 2678 |
+
public function getEarlyFeeDate() { return $this->earlyFeeDate; }
|
| 2679 |
+
|
| 2680 |
+
public function setLateFeeDate( $value ) { $this->lateFeeDate = $value; }
|
| 2681 |
+
public function getLateFeeDate() { return $this->lateFeeDate; }
|
| 2682 |
+
|
| 2683 |
+
public function setGuestLimit( $value ) { $this->guestLimit = $value; }
|
| 2684 |
+
public function getGuestLimit() { return $this->guestLimit; }
|
| 2685 |
+
|
| 2686 |
+
public function setTicketing( $value ) { $this->ticketing = $value; }
|
| 2687 |
+
public function getTicketing() { return $this->ticketing; }
|
| 2688 |
+
|
| 2689 |
+
public function setEventFee( $value ) { $this->eventFee[] = $value; }
|
| 2690 |
+
public function getEventFee() { return $this->eventFee; }
|
| 2691 |
+
}
|
| 2692 |
+
/**
|
| 2693 |
+
* Registrant class defines a registrant object
|
| 2694 |
+
*
|
| 2695 |
+
* Defines a registrant object, includes all campaign variables as well as the
|
| 2696 |
+
* getters and setters for variables
|
| 2697 |
+
*
|
| 2698 |
+
*/
|
| 2699 |
+
class Registrant
|
| 2700 |
+
{
|
| 2701 |
+
/**
|
| 2702 |
+
* Construct function for the Registrant Class
|
| 2703 |
+
*
|
| 2704 |
+
* @param array $params - an array of variables that set up a registrant object
|
| 2705 |
+
* @return object registrant object with passed variables set to the object
|
| 2706 |
+
*/
|
| 2707 |
+
public function __construct($params = array())
|
| 2708 |
+
{
|
| 2709 |
+
$this->setLink($params['registrant_link']);
|
| 2710 |
+
$this->setLastName($params['last_name']);
|
| 2711 |
+
$this->setFirstName($params['first_name']);
|
| 2712 |
+
$this->setEmailAddress($params['email_address']);
|
| 2713 |
+
$this->setPersonalLabel($params['personal_label']);
|
| 2714 |
+
$this->setPersonalAddr1($params['personal_addr1']);
|
| 2715 |
+
$this->setPersonalAddr2($params['personal_addr2']);
|
| 2716 |
+
$this->setPersonalAddr3($params['personal_addr3']);
|
| 2717 |
+
$this->setPersonalCity($params['personal_city']);
|
| 2718 |
+
$this->setPersonalState($params['personal_state']);
|
| 2719 |
+
$this->setPersonalPostalCode($params['personal_postalcode']);
|
| 2720 |
+
$this->setPersonalProvince($params['personal_province']);
|
| 2721 |
+
$this->setPersonalCountry($params['personal_country']);
|
| 2722 |
+
$this->setPersonalPhone($params['personal_phone']);
|
| 2723 |
+
$this->setPersonalCellPhone($params['personal_cellphone']);
|
| 2724 |
+
$this->setBusinessLabel($params['business_label']);
|
| 2725 |
+
$this->setBusinessCompany($params['business_company']);
|
| 2726 |
+
$this->setBusinessJobTitle($params['business_jobtitle']);
|
| 2727 |
+
$this->setBusinessDepartment($params['business_department']);
|
| 2728 |
+
$this->setBusinessAddr1($params['business_addr1']);
|
| 2729 |
+
$this->setBusinessAddr2($params['business_addr2']);
|
| 2730 |
+
$this->setBusinessAddr3($params['business_addr3']);
|
| 2731 |
+
$this->setBusinessCity($params['business_city']);
|
| 2732 |
+
$this->setBusinessState($params['business_state']);
|
| 2733 |
+
$this->setBusinessPostalCode($params['business_postalcode']);
|
| 2734 |
+
$this->setBusinessProvince($params['business_province']);
|
| 2735 |
+
$this->setBusinessCountry($params['business_country']);
|
| 2736 |
+
$this->setBusinessPhone($params['business_phone']);
|
| 2737 |
+
$this->setBusinessFax($params['business_fax']);
|
| 2738 |
+
$this->setBusinessWebSite($params['business_website']);
|
| 2739 |
+
$this->setBusinessBlog($params['business_blog']);
|
| 2740 |
+
$this->setRegistrationStatus($params['reg_status']);
|
| 2741 |
+
$this->setRegistrationDate($params['reg_date']);
|
| 2742 |
+
$this->setGuestCount($params['guest_count']);
|
| 2743 |
+
$this->setPaymentStatus($params['payment_status']);
|
| 2744 |
+
$this->setOrderAmount($params['order_amount']);
|
| 2745 |
+
$this->setCurrencyType($params['currency_type']);
|
| 2746 |
+
$this->setPaymentType($params['payment_type']);
|
| 2747 |
+
|
| 2748 |
+
if ($params['custom_field1'])
|
| 2749 |
+
{
|
| 2750 |
+
foreach ($params['custom_field1'] as $tmp)
|
| 2751 |
+
{
|
| 2752 |
+
$this->setCustomField1($tmp);
|
| 2753 |
+
}
|
| 2754 |
+
}
|
| 2755 |
+
|
| 2756 |
+
if ($params['custom_field2'])
|
| 2757 |
+
{
|
| 2758 |
+
foreach ($params['custom_field2'] as $tmp)
|
| 2759 |
+
{
|
| 2760 |
+
$this->setCustomField2($tmp);
|
| 2761 |
+
}
|
| 2762 |
+
}
|
| 2763 |
+
|
| 2764 |
+
if ($params['costs'])
|
| 2765 |
+
{
|
| 2766 |
+
foreach ($params['costs'] as $tmp)
|
| 2767 |
+
{
|
| 2768 |
+
$this->setCost($tmp);
|
| 2769 |
+
}
|
| 2770 |
+
}
|
| 2771 |
+
|
| 2772 |
+
return $this;
|
| 2773 |
+
}
|
| 2774 |
+
|
| 2775 |
+
private $link;
|
| 2776 |
+
private $lastName;
|
| 2777 |
+
private $firstName;
|
| 2778 |
+
private $emailAddress;
|
| 2779 |
+
private $personalLabel;
|
| 2780 |
+
private $personalAddr1;
|
| 2781 |
+
private $personalAddr2;
|
| 2782 |
+
private $personalAddr3;
|
| 2783 |
+
private $personalCity;
|
| 2784 |
+
private $personalState;
|
| 2785 |
+
private $personalPostalCode;
|
| 2786 |
+
private $personalProvince;
|
| 2787 |
+
private $personalCountry;
|
| 2788 |
+
private $personalPhone;
|
| 2789 |
+
private $personalCellPhone;
|
| 2790 |
+
private $businessLabel;
|
| 2791 |
+
private $businessCompany;
|
| 2792 |
+
private $businessJobTitle;
|
| 2793 |
+
private $businessDepartment;
|
| 2794 |
+
private $businessAddr1;
|
| 2795 |
+
private $businessAddr2;
|
| 2796 |
+
private $businessAddr3;
|
| 2797 |
+
private $businessCity;
|
| 2798 |
+
private $businessState;
|
| 2799 |
+
private $businessPostalCode;
|
| 2800 |
+
private $businessProvince;
|
| 2801 |
+
private $businessCountry;
|
| 2802 |
+
private $businessPhone;
|
| 2803 |
+
private $businessFax;
|
| 2804 |
+
private $businessWebSite;
|
| 2805 |
+
private $businessBlog;
|
| 2806 |
+
private $customField1 = array();
|
| 2807 |
+
private $customField2 = array();
|
| 2808 |
+
private $registrationStatus;
|
| 2809 |
+
private $registrationDate;
|
| 2810 |
+
private $guestCount;
|
| 2811 |
+
private $paymentStatus;
|
| 2812 |
+
private $orderAmount;
|
| 2813 |
+
private $currencyType;
|
| 2814 |
+
private $paymentType;
|
| 2815 |
+
private $costs = array();
|
| 2816 |
+
|
| 2817 |
+
public function setLink( $value ) { $this->link = $value; }
|
| 2818 |
+
public function getLink() { return $this->link; }
|
| 2819 |
+
|
| 2820 |
+
public function setLastName( $value ) { $this->lastName = $value; }
|
| 2821 |
+
public function getLastName() { return $this->lastName; }
|
| 2822 |
+
|
| 2823 |
+
public function setFirstName( $value ) { $this->firstName = $value; }
|
| 2824 |
+
public function getFirstName() { return $this->firstName; }
|
| 2825 |
+
|
| 2826 |
+
public function setEmailAddress( $value ) { $this->emailAddress = $value; }
|
| 2827 |
+
public function getEmailAddress() { return $this->emailAddress; }
|
| 2828 |
+
|
| 2829 |
+
public function setPersonalLabel( $value ) { $this->personalLabel = $value; }
|
| 2830 |
+
public function getPersonalLabel() { return $this->personalLabel; }
|
| 2831 |
+
|
| 2832 |
+
public function setPersonalAddr1( $value ) { $this->personalAddr1 = $value; }
|
| 2833 |
+
public function getPersonalAddr1() { return $this->personalAddr1; }
|
| 2834 |
+
|
| 2835 |
+
public function setPersonalAddr2( $value ) { $this->personalAddr2 = $value; }
|
| 2836 |
+
public function getPersonalAddr2() { return $this->personalAddr2; }
|
| 2837 |
+
|
| 2838 |
+
public function setPersonalAddr3( $value ) { $this->personalAddr3 = $value; }
|
| 2839 |
+
public function getPersonalAddr3() { return $this->personalAddr3; }
|
| 2840 |
+
|
| 2841 |
+
public function setPersonalCity( $value ) { $this->personalCity = $value; }
|
| 2842 |
+
public function getPersonalCity() { return $this->personalCity; }
|
| 2843 |
+
|
| 2844 |
+
public function setPersonalState( $value ) { $this->personalState = $value; }
|
| 2845 |
+
public function getPersonalState() { return $this->personalState; }
|
| 2846 |
+
|
| 2847 |
+
public function setPersonalPostalCode( $value ) { $this->personalPostalCode = $value; }
|
| 2848 |
+
public function getPersonalPostalCode() { return $this->personalPostalCode; }
|
| 2849 |
+
|
| 2850 |
+
public function setPersonalProvince( $value ) { $this->personalProvince = $value; }
|
| 2851 |
+
public function getPersonalProvince() { return $this->personalProvince; }
|
| 2852 |
+
|
| 2853 |
+
public function setPersonalCountry( $value ) { $this->personalCountry = $value; }
|
| 2854 |
+
public function getPersonalCountry() { return $this->personalCountry; }
|
| 2855 |
+
|
| 2856 |
+
public function setPersonalPhone( $value ) { $this->personalPhone = $value; }
|
| 2857 |
+
public function getPersonalPhone() { return $this->personalPhone; }
|
| 2858 |
+
|
| 2859 |
+
public function setPersonalCellPhone( $value ) { $this->personalCellPhone = $value; }
|
| 2860 |
+
public function getPersonalCellPhone() { return $this->personalCellPhone; }
|
| 2861 |
+
|
| 2862 |
+
public function setBusinessLabel( $value ) { $this->businessLabel = $value; }
|
| 2863 |
+
public function getBusinessLabel() { return $this->businessLabel; }
|
| 2864 |
+
|
| 2865 |
+
public function setBusinessCompany( $value ) { $this->businessCompany = $value; }
|
| 2866 |
+
public function getBusinessCompany() { return $this->businessCompany; }
|
| 2867 |
+
|
| 2868 |
+
public function setBusinessJobTitle( $value ) { $this->businessJobTitle = $value; }
|
| 2869 |
+
public function getBusinessJobTitle() { return $this->businessJobTitle; }
|
| 2870 |
+
|
| 2871 |
+
public function setBusinessDepartment( $value ) { $this->businessDepartment = $value; }
|
| 2872 |
+
public function getBusinessDepartment() { return $this->businessDepartment; }
|
| 2873 |
+
|
| 2874 |
+
public function setBusinessAddr1( $value ) { $this->businessAddr1 = $value; }
|
| 2875 |
+
public function getBusinessAddr1() { return $this->businessAddr1; }
|
| 2876 |
+
|
| 2877 |
+
public function setBusinessAddr2( $value ) { $this->businessAddr2 = $value; }
|
| 2878 |
+
public function getBusinessAddr2() { return $this->businessAddr2; }
|
| 2879 |
+
|
| 2880 |
+
public function setBusinessAddr3( $value ) { $this->businessAddr3 = $value; }
|
| 2881 |
+
public function getBusinessAddr3() { return $this->businessAddr3; }
|
| 2882 |
+
|
| 2883 |
+
public function setBusinessCity( $value ) { $this->businessCity = $value; }
|
| 2884 |
+
public function getBusinessCity() { return $this->businessCity; }
|
| 2885 |
+
|
| 2886 |
+
public function setBusinessState( $value ) { $this->businessState = $value; }
|
| 2887 |
+
public function getBusinessState() { return $this->businessState; }
|
| 2888 |
+
|
| 2889 |
+
public function setBusinessPostalCode( $value ) { $this->businessPostalCode = $value; }
|
| 2890 |
+
public function getBusinessPostalCode() { return $this->businessPostalCode; }
|
| 2891 |
+
|
| 2892 |
+
public function setBusinessProvince( $value ) { $this->businessProvince = $value; }
|
| 2893 |
+
public function getBusinessProvince() { return $this->businessProvince; }
|
| 2894 |
+
|
| 2895 |
+
public function setBusinessCountry( $value ) { $this->businessCountry = $value; }
|
| 2896 |
+
public function getBusinessCountry() { return $this->businessCountry; }
|
| 2897 |
+
|
| 2898 |
+
public function setBusinessPhone( $value ) { $this->businessPhone = $value; }
|
| 2899 |
+
public function getBusinessPhone() { return $this->businessPhone; }
|
| 2900 |
+
|
| 2901 |
+
public function setBusinessFax( $value ) { $this->businessFax = $value; }
|
| 2902 |
+
public function getBusinessFax() { return $this->businessFax; }
|
| 2903 |
+
|
| 2904 |
+
public function setBusinessWebSite( $value ) { $this->businessWebSite = $value; }
|
| 2905 |
+
public function getBusinessWebSite() { return $this->businessWebSite; }
|
| 2906 |
+
|
| 2907 |
+
public function setBusinessBlog( $value ) { $this->businessBlog = $value; }
|
| 2908 |
+
public function getBusinessBlog() { return $this->businessBlog; }
|
| 2909 |
+
|
| 2910 |
+
public function setCustomField( $value ) { $this->customField[] = $value; }
|
| 2911 |
+
public function getCustomField() { return $this->customField; }
|
| 2912 |
+
|
| 2913 |
+
public function setRegistrationStatus( $value ) { $this->registrationStatus = $value; }
|
| 2914 |
+
public function getRegistrationStatus() { return $this->registrationStatus; }
|
| 2915 |
+
|
| 2916 |
+
public function setRegistrationDate( $value ) { $this->registrationDate = $value; }
|
| 2917 |
+
public function getRegistrationDate() { return $this->registrationDate; }
|
| 2918 |
+
|
| 2919 |
+
public function setGuestCount( $value ) { $this->guestCount = $value; }
|
| 2920 |
+
public function getGuestCount() { return $this->guestCount; }
|
| 2921 |
+
|
| 2922 |
+
public function setPaymentStatus( $value ) { $this->paymentStatus = $value; }
|
| 2923 |
+
public function getPaymentStatus() { return $this->paymentStatus; }
|
| 2924 |
+
|
| 2925 |
+
public function setOrderAmount( $value ) { $this->orderAmount = $value; }
|
| 2926 |
+
public function getOrderAmount() { return $this->orderAmount; }
|
| 2927 |
+
|
| 2928 |
+
public function setCurrencyType( $value ) { $this->currencyType = $value; }
|
| 2929 |
+
public function getCurrencyType() { return $this->currencyType; }
|
| 2930 |
+
|
| 2931 |
+
public function setPaymentType( $value ) { $this->paymentType = $value; }
|
| 2932 |
+
public function getPaymentType() { return $this->paymentType; }
|
| 2933 |
+
|
| 2934 |
+
public function setCost( $value ) { $this->costs[] = $value; }
|
| 2935 |
+
public function getCost() { return $this->costs; }
|
| 2936 |
+
|
| 2937 |
+
public function setCustomField1( $value ) { $this->customField1[] = $value; }
|
| 2938 |
+
public function getCustomField1() { return $this->customField1; }
|
| 2939 |
+
|
| 2940 |
+
public function setCustomField2( $value ) { $this->customField2[] = $value; }
|
| 2941 |
+
public function getCustomField2() { return $this->customField2; }
|
| 2942 |
+
}
|
| 2943 |
+
/**
|
| 2944 |
+
* Event Collection Class for calls to the event collection API
|
| 2945 |
+
*
|
| 2946 |
+
* Includes functions for listing all events within the account, specific event details,
|
| 2947 |
+
* also listing registrants and registrant details.
|
| 2948 |
+
*
|
| 2949 |
+
*/
|
| 2950 |
+
class EventCollection
|
| 2951 |
+
{
|
| 2952 |
+
/**
|
| 2953 |
+
* Public function that gets a list of first 50 events in the account
|
| 2954 |
+
*
|
| 2955 |
+
* @return array $allEvents - an array of two arrays, array 1 is event objects, array 2 is link for next 50 events
|
| 2956 |
+
*/
|
| 2957 |
+
public function listEvents()
|
| 2958 |
+
{
|
| 2959 |
+
$utility = new Utility();
|
| 2960 |
+
$return = $utility->httpGet($utility->getApiPath() . '/ws/customers/'. $utility->getLogin() .'/events');
|
| 2961 |
+
$allEvents = array();
|
| 2962 |
+
$eventArray = array();
|
| 2963 |
+
$returnedXml = str_replace('atom:', '', $return['xml']);
|
| 2964 |
+
$eventList = array();
|
| 2965 |
+
$pages = array();
|
| 2966 |
+
$xml = simplexml_load_string($returnedXml);
|
| 2967 |
+
|
| 2968 |
+
foreach ($xml->entry as $item)
|
| 2969 |
+
{
|
| 2970 |
+
$eventArray['event_link'] = ($item->link['href']);
|
| 2971 |
+
$eventArray['event_name'] = ($item->content->Event->Name);
|
| 2972 |
+
$eventArray['event_description'] = ($item->content->Event->Description);
|
| 2973 |
+
$eventArray['event_title'] = ($item->Event->content->Title);
|
| 2974 |
+
$eventArray['registered'] = ($item->content->Event->Registered);
|
| 2975 |
+
$eventArray['created_date'] = ($item->content->Event->CreatedDate);
|
| 2976 |
+
$eventArray['event_status'] = ($item->content->Event->Status);
|
| 2977 |
+
$eventArray['event_type'] = ($item->content->Event->EventType);
|
| 2978 |
+
$eventArray['event_start'] = ($item->content->Event->StartDate);
|
| 2979 |
+
$eventArray['event_end'] = ($item->content->Event->EndDate);
|
| 2980 |
+
$eventArray['event_publishdate'] = ($item->content->Event->PublishDate);
|
| 2981 |
+
$eventArray['event_webpage'] = ($item->content->Event->WebPage);
|
| 2982 |
+
$eventArray['attended_count'] = ($item->content->Event->AttendedCount);
|
| 2983 |
+
$eventArray['cancelled_count'] = ($item->content->Event->CancelledCount);
|
| 2984 |
+
$eventArray['location'] = ($item->content->Event->EventLocation->Location);
|
| 2985 |
+
$eventArray['event_addr1'] = ($item->content->Event->EventLocation->Address1);
|
| 2986 |
+
$eventArray['event_addr2'] = ($item->content->Event->EventLocation->Address2);
|
| 2987 |
+
$eventArray['event_addr3'] = ($item->content->Event->EventLocation->Address3);
|
| 2988 |
+
$eventArray['event_city'] = ($item->content->Event->EventLocation->City);
|
| 2989 |
+
$eventArray['event_state'] = ($item->content->Event->EventLocation->State);
|
| 2990 |
+
$eventArray['event_country'] = ($item->content->Event->EventLocation->Country);
|
| 2991 |
+
$eventArray['event_postalcode'] = ($item->content->Event->EventLocation->PostalCode);
|
| 2992 |
+
$event = new Event($eventArray);
|
| 2993 |
+
$eventList[] = $event;
|
| 2994 |
+
}
|
| 2995 |
+
|
| 2996 |
+
if ($xml->link[2])
|
| 2997 |
+
{
|
| 2998 |
+
$pages[] = $xml->link[2]->Attributes()->href;
|
| 2999 |
+
}
|
| 3000 |
+
|
| 3001 |
+
$allEvents= array($eventList, $pages);
|
| 3002 |
+
|
| 3003 |
+
return $allEvents;
|
| 3004 |
+
}
|
| 3005 |
+
/**
|
| 3006 |
+
* Public function that gets event details of a single event object passed to it.
|
| 3007 |
+
*
|
| 3008 |
+
* @param object $event - a valid event object with a valid event link
|
| 3009 |
+
* @return object $event - returns event object with full details
|
| 3010 |
+
*/
|
| 3011 |
+
public function listEventDetails($event)
|
| 3012 |
+
{
|
| 3013 |
+
$utility = new Utility();
|
| 3014 |
+
$call = $utility->getApiPath() . $event->getLink();
|
| 3015 |
+
$return = $utility->httpGet($call);
|
| 3016 |
+
$event = $this->createEventStruct($return['xml']);
|
| 3017 |
+
if (!$return)
|
| 3018 |
+
{
|
| 3019 |
+
return false;
|
| 3020 |
+
}
|
| 3021 |
+
else
|
| 3022 |
+
{
|
| 3023 |
+
return $event;
|
| 3024 |
+
}
|
| 3025 |
+
}
|
| 3026 |
+
/**
|
| 3027 |
+
* Public function that gets a list of first 50 registrants in an event
|
| 3028 |
+
*
|
| 3029 |
+
* @param object $event - a valid event object with a valid event link
|
| 3030 |
+
* @return array $allRegistrants - an array of two arrays, array 1 is registrant objects, array 2 is link for next 50 registrant
|
| 3031 |
+
*/
|
| 3032 |
+
public function listEventRegistrants($event)
|
| 3033 |
+
{
|
| 3034 |
+
$utility = new Utility();
|
| 3035 |
+
$return = $utility->httpGet($utility->getApiPath() . $event->getLink() . '/registrants');
|
| 3036 |
+
$allRegistrants = array();
|
| 3037 |
+
$registrantArray = array();
|
| 3038 |
+
$returnedXml = str_replace('atom:', '', $return['xml']);
|
| 3039 |
+
$registrantList = array();
|
| 3040 |
+
$pages = array();
|
| 3041 |
+
$xml = simplexml_load_string($returnedXml);
|
| 3042 |
+
|
| 3043 |
+
foreach ($xml->entry as $item)
|
| 3044 |
+
{
|
| 3045 |
+
$registrantArray['registrant_link'] = ($item->link['href']);
|
| 3046 |
+
$registrantArray['last_name'] = ($item->content->Registrant->LastName);
|
| 3047 |
+
$registrantArray['first_name'] = ($item->content->Registrant->FirstName);
|
| 3048 |
+
$registrantArray['email_address'] = ($item->content->Registrant->EmailAddress);
|
| 3049 |
+
$registrantArray['reg_status'] = ($item->content->Registrant->RegistrationStatus);
|
| 3050 |
+
$registrantArray['reg_date'] = ($item->content->Registrant->RegistrationDate);
|
| 3051 |
+
$registrantArray['guest_count'] = ($item->content->Registrant->GuestCount);
|
| 3052 |
+
$registrantArray['payment_status'] = ($item->content->Registrant->PaymentStatus);
|
| 3053 |
+
$registrant = new Registrant($registrantArray);
|
| 3054 |
+
$registrantList[] = $registrant;
|
| 3055 |
+
}
|
| 3056 |
+
|
| 3057 |
+
if ($xml->link[2])
|
| 3058 |
+
{
|
| 3059 |
+
$pages[] = $xml->link[2]->Attributes()->href;
|
| 3060 |
+
}
|
| 3061 |
+
|
| 3062 |
+
$allRegistrants = array($registrantList, $pages);
|
| 3063 |
+
|
| 3064 |
+
return $allRegistrants;
|
| 3065 |
+
}
|
| 3066 |
+
/**
|
| 3067 |
+
* Public function that gets event details of a single event object passed to it.
|
| 3068 |
+
*
|
| 3069 |
+
* @param object $registrant - a valid registrant object with a valid registrant link
|
| 3070 |
+
* @return object $registrant - returns registrant object with full details
|
| 3071 |
+
*/
|
| 3072 |
+
public function listRegistrantDetails($registrant)
|
| 3073 |
+
{
|
| 3074 |
+
$utility = new Utility();
|
| 3075 |
+
$call = $utility->getApiPath() . $registrant->getLink();
|
| 3076 |
+
$return = $utility->httpGet($call);
|
| 3077 |
+
$registrant = $this->createRegistrantStruct($return['xml']);
|
| 3078 |
+
if (!$return)
|
| 3079 |
+
{
|
| 3080 |
+
return false;
|
| 3081 |
+
}
|
| 3082 |
+
else
|
| 3083 |
+
{
|
| 3084 |
+
return $registrant;
|
| 3085 |
+
}
|
| 3086 |
+
}
|
| 3087 |
+
/**
|
| 3088 |
+
* Private function that creates an event object from XML
|
| 3089 |
+
*
|
| 3090 |
+
* @param string $eventXml - Valid event XML
|
| 3091 |
+
* @return object $eventStruct - returns a valid event object
|
| 3092 |
+
*/
|
| 3093 |
+
private function createEventStruct($eventXml)
|
| 3094 |
+
{
|
| 3095 |
+
$eventArray = array();
|
| 3096 |
+
$eventXml = str_replace('atom:', '', $eventXml);
|
| 3097 |
+
$parsedReturn = simplexml_load_string($eventXml);
|
| 3098 |
+
$eventArray['event_link'] = ($parsedReturn->link->Attributes()->href);
|
| 3099 |
+
$eventArray['event_name'] = ($parsedReturn->content->Event->Name);
|
| 3100 |
+
$eventArray['event_description'] = ($parsedReturn->content->Event->Description);
|
| 3101 |
+
$eventArray['event_title'] = ($parsedReturn->content->Event->Title);
|
| 3102 |
+
$eventArray['registered'] = ($parsedReturn->content->Event->Registered);
|
| 3103 |
+
$eventArray['created_date'] = ($parsedReturn->content->Event->CreatedDate);
|
| 3104 |
+
$eventArray['event_status'] = ($parsedReturn->content->Event->Status);
|
| 3105 |
+
$eventArray['event_type'] = ($parsedReturn->content->Event->EventType);
|
| 3106 |
+
$eventArray['location'] = ($parsedReturn->content->Event->EventLocation->Location);
|
| 3107 |
+
$eventArray['event_addr1'] = ($parsedReturn->content->Event->EventLocation->Address1);
|
| 3108 |
+
$eventArray['event_addr2'] = ($parsedReturn->content->Event->EventLocation->Address2);
|
| 3109 |
+
$eventArray['event_addr3'] = ($parsedReturn->content->Event->EventLocation->Address3);
|
| 3110 |
+
$eventArray['event_city'] = ($parsedReturn->content->Event->EventLocation->City);
|
| 3111 |
+
$eventArray['event_state'] = ($parsedReturn->content->Event->EventLocation->State);
|
| 3112 |
+
$eventArray['event_country'] = ($parsedReturn->content->Event->EventLocation->Country);
|
| 3113 |
+
$eventArray['event_postalcode'] = ($parsedReturn->content->Event->EventLocation->PostalCode);
|
| 3114 |
+
$eventArray['registration_url'] = ($parsedReturn->content->Event->RegistrationURL);
|
| 3115 |
+
$eventArray['event_start'] = ($parsedReturn->content->Event->StartDate);
|
| 3116 |
+
$eventArray['event_end'] = ($parsedReturn->content->Event->EndDate);
|
| 3117 |
+
$eventArray['event_publishdate'] = ($parsedReturn->content->Event->PublishDate);
|
| 3118 |
+
$eventArray['event_webpage'] = ($parsedReturn->content->Event->WebPage);
|
| 3119 |
+
$eventArray['attended_count'] = ($parsedReturn->content->Event->AttendedCount);
|
| 3120 |
+
$eventArray['cancelled_count'] = ($parsedReturn->content->Event->CancelledCount);
|
| 3121 |
+
$eventArray['event_fee_required'] = ($parsedReturn->content->Event->EventFeeRequired);
|
| 3122 |
+
$eventArray['currency_type'] = ($parsedReturn->content->Event->CurrencyType);
|
| 3123 |
+
$eventArray['reg_limit_date'] = ($parsedReturn->content->Event->RegistrationTypes->RegistrationType->RegistrationLimitDate);
|
| 3124 |
+
$eventArray['reg_limit_count'] = ($parsedReturn->content->Event->RegistrationTypes->RegistrationType->RegistrationLimitCount);
|
| 3125 |
+
$eventArray['reg_closed_manually'] = ($parsedReturn->content->Event->RegistrationTypes->RegistrationType->RegistrationClosedManually);
|
| 3126 |
+
$eventArray['early_fee_date'] = ($parsedReturn->content->Event->RegistrationTypes->RegistrationType->EarlyFeeDate);
|
| 3127 |
+
$eventArray['late_fee_date'] = ($parsedReturn->content->Event->RegistrationTypes->RegistrationType->LateFeeDate);
|
| 3128 |
+
$eventArray['guest_limit'] = ($parsedReturn->content->Event->RegistrationTypes->RegistrationType->GuestLimit);
|
| 3129 |
+
$eventArray['ticketing'] = ($parsedReturn->content->Event->RegistrationTypes->RegistrationType->Ticketing);
|
| 3130 |
+
|
| 3131 |
+
if ($parsedReturn->content->Event->PaymentOptions)
|
| 3132 |
+
{
|
| 3133 |
+
foreach ($parsedReturn->content->Event->PaymentOptions->PaymentOption as $item)
|
| 3134 |
+
{
|
| 3135 |
+
$type = $item->Type;
|
| 3136 |
+
if ($type == 'PAYPAL')
|
| 3137 |
+
{
|
| 3138 |
+
$eventArray['payment_options']['paypal']['email_address'] = (trim((string) $item->PayPalAccountEmail));
|
| 3139 |
+
}
|
| 3140 |
+
if ($type == 'CHECK')
|
| 3141 |
+
{
|
| 3142 |
+
$eventArray['payment_options']['check']['address1'] = (trim((string) $item->PaymentAddress->Address1));
|
| 3143 |
+
$eventArray['payment_options']['check']['address2'] = (trim((string) $item->PaymentAddress->Address2));
|
| 3144 |
+
$eventArray['payment_options']['check']['address3'] = (trim((string) $item->PaymentAddress->Address3));
|
| 3145 |
+
$eventArray['payment_options']['check']['city'] = (trim((string) $item->PaymentAddress->City));
|
| 3146 |
+
$eventArray['payment_options']['check']['state'] = (trim((string) $item->PaymentAddress->State));
|
| 3147 |
+
$eventArray['payment_options']['check']['country'] = (trim((string) $item->PaymentAddress->Country));
|
| 3148 |
+
$eventArray['payment_options']['check']['postal_code'] = (trim((string) $item->PaymentAddress->PostalCode));
|
| 3149 |
+
}
|
| 3150 |
+
if ($type == 'DOOR')
|
| 3151 |
+
{
|
| 3152 |
+
$eventArray['payment_options']['door']['DOOR'] = 'Pay at the Door';
|
| 3153 |
+
}
|
| 3154 |
+
}
|
| 3155 |
+
}
|
| 3156 |
+
|
| 3157 |
+
if ($parsedReturn->content->Event->RegistrationTypes->RegistrationType->EventFees)
|
| 3158 |
+
{
|
| 3159 |
+
$int = 1;
|
| 3160 |
+
foreach ($parsedReturn->content->Event->RegistrationTypes->RegistrationType->EventFees->EventFee as $item)
|
| 3161 |
+
{
|
| 3162 |
+
$int++;
|
| 3163 |
+
$eventArray['event_fees']['event_fee' . $int]['Label'] = (trim((string) $item->Label));
|
| 3164 |
+
$eventArray['event_fees']['event_fee' . $int]['Fee'] = (trim((string) $item->Fee));
|
| 3165 |
+
$eventArray['event_fees']['event_fee' . $int]['EarlyFee'] = (trim((string) $item->EarlyFee));
|
| 3166 |
+
$eventArray['event_fees']['event_fee' . $int]['LateFee'] = (trim((string) $item->LateFee));
|
| 3167 |
+
$eventArray['event_fees']['event_fee' . $int]['FeeScope'] = (trim((string) $item->FeeScope));
|
| 3168 |
+
}
|
| 3169 |
+
}
|
| 3170 |
+
$eventStruct = new Event($eventArray);
|
| 3171 |
+
return $eventStruct;
|
| 3172 |
+
|
| 3173 |
+
}
|
| 3174 |
+
/**
|
| 3175 |
+
* Private function that creates an registrant object from XML
|
| 3176 |
+
*
|
| 3177 |
+
* @param string $registrantXml - Valid registrant XML
|
| 3178 |
+
* @return object $registrantStruct - returns a valid registrant object
|
| 3179 |
+
*/
|
| 3180 |
+
private function createRegistrantStruct($registrantXml)
|
| 3181 |
+
{
|
| 3182 |
+
$registrantArray = array();
|
| 3183 |
+
$registrantXml = str_replace('atom:', '', $registrantXml);
|
| 3184 |
+
$parsedReturn = simplexml_load_string($registrantXml);
|
| 3185 |
+
$registrantArray['registrant_link'] = ($parsedReturn->link->Attributes()->href);
|
| 3186 |
+
$registrantArray['last_name'] = ($parsedReturn->content->Registrant->LastName);
|
| 3187 |
+
$registrantArray['first_name'] = ($parsedReturn->content->Registrant->FirstName);
|
| 3188 |
+
$registrantArray['email_address'] = ($parsedReturn->content->Registrant->EmailAddress);
|
| 3189 |
+
$registrantArray['personal_label'] = ($parsedReturn->content->Registrant->PersonalInformation->Label);
|
| 3190 |
+
$registrantArray['personal_addr1'] = ($parsedReturn->content->Registrant->PersonalInformation->Address1);
|
| 3191 |
+
$registrantArray['personal_addr2'] = ($parsedReturn->content->Registrant->PersonalInformation->Address2);
|
| 3192 |
+
$registrantArray['personal_addr3'] = ($parsedReturn->content->Registrant->PersonalInformation->Address3);
|
| 3193 |
+
$registrantArray['personal_city'] = ($parsedReturn->content->Registrant->PersonalInformation->City);
|
| 3194 |
+
$registrantArray['personal_state'] = ($parsedReturn->content->Registrant->PersonalInformation->State);
|
| 3195 |
+
$registrantArray['personal_postalcode'] = ($parsedReturn->content->Registrant->PersonalInformation->PostalCode);
|
| 3196 |
+
$registrantArray['personal_province'] = ($parsedReturn->content->Registrant->PersonalInformation->Province);
|
| 3197 |
+
$registrantArray['personal_country'] = ($parsedReturn->content->Registrant->PersonalInformation->Country);
|
| 3198 |
+
$registrantArray['personal_phone'] = ($parsedReturn->content->Registrant->PersonalInformation->Phone);
|
| 3199 |
+
$registrantArray['personal_cellphone'] = ($parsedReturn->content->Registrant->PersonalInformation->CellPhone);
|
| 3200 |
+
$registrantArray['business_label'] = ($parsedReturn->content->Registrant->BusinessInformation->Label);
|
| 3201 |
+
$registrantArray['business_company'] = ($parsedReturn->content->Registrant->BusinessInformation->Company);
|
| 3202 |
+
$registrantArray['business_jobtitle'] = ($parsedReturn->content->Registrant->BusinessInformation->JobTitle);
|
| 3203 |
+
$registrantArray['business_department'] = ($parsedReturn->content->Registrant->BusinessInformation->Department);
|
| 3204 |
+
$registrantArray['business_addr1'] = ($parsedReturn->content->Registrant->BusinessInformation->Address1);
|
| 3205 |
+
$registrantArray['business_addr2'] = ($parsedReturn->content->Registrant->BusinessInformation->Address2);
|
| 3206 |
+
$registrantArray['business_addr3'] = ($parsedReturn->content->Registrant->BusinessInformation->Address3);
|
| 3207 |
+
$registrantArray['business_city'] = ($parsedReturn->content->Registrant->BusinessInformation->City);
|
| 3208 |
+
$registrantArray['business_state'] = ($parsedReturn->content->Registrant->BusinessInformation->State);
|
| 3209 |
+
$registrantArray['business_postalcode'] = ($parsedReturn->content->Registrant->BusinessInformation->PostalCode);
|
| 3210 |
+
$registrantArray['business_province'] = ($parsedReturn->content->Registrant->BusinessInformation->Province);
|
| 3211 |
+
$registrantArray['business_country'] = ($parsedReturn->content->Registrant->BusinessInformation->Country);
|
| 3212 |
+
$registrantArray['business_phone'] = ($parsedReturn->content->Registrant->BusinessInformation->Phone);
|
| 3213 |
+
$registrantArray['business_fax'] = ($parsedReturn->content->Registrant->BusinessInformation->Fax);
|
| 3214 |
+
$registrantArray['business_website'] = ($parsedReturn->content->Registrant->BusinessInformation->Website);
|
| 3215 |
+
$registrantArray['business_blog'] = ($parsedReturn->content->Registrant->BusinessInformation->Blog);
|
| 3216 |
+
$registrantArray['reg_status'] = ($parsedReturn->content->Registrant->RegistrationStatus);
|
| 3217 |
+
$registrantArray['reg_date'] = ($parsedReturn->content->Registrant->RegistrationDate);
|
| 3218 |
+
$registrantArray['guest_count'] = ($parsedReturn->content->Registrant->GuestCount);
|
| 3219 |
+
$registrantArray['payment_status'] = ($parsedReturn->content->Registrant->PaymentStatus);
|
| 3220 |
+
$registrantArray['order_amount'] = ($parsedReturn->content->Registrant->OrderAmount);
|
| 3221 |
+
$registrantArray['currency_type'] = ($parsedReturn->content->Registrant->CurrencyType);
|
| 3222 |
+
$registrantArray['payment_type'] = ($parsedReturn->content->Registrant->PaymentType);
|
| 3223 |
+
|
| 3224 |
+
if ($parsedReturn->content->Registrant->CustomInformation1)
|
| 3225 |
+
{
|
| 3226 |
+
$int = 1;
|
| 3227 |
+
foreach ($parsedReturn->content->Registrant->CustomInformation1->CustomField as $item)
|
| 3228 |
+
{
|
| 3229 |
+
$int++;
|
| 3230 |
+
$registrantArray['custom_field1']['custom_field' . $int]['Question'] = (trim((string) $item->Question));
|
| 3231 |
+
$registrantArray['custom_field1']['custom_field' . $int]['Answer'] = (trim((string) $item->Answers->Answer));
|
| 3232 |
+
}
|
| 3233 |
+
}
|
| 3234 |
+
if ($parsedReturn->content->Registrant->CustomInformation2)
|
| 3235 |
+
{
|
| 3236 |
+
$int = 1;
|
| 3237 |
+
foreach ($parsedReturn->content->Registrant->CustomInformation2->CustomField as $item)
|
| 3238 |
+
{
|
| 3239 |
+
$int++;
|
| 3240 |
+
$registrantArray['custom_field2']['custom_field' . $int]['Question'] = (trim((string) $item->Question));
|
| 3241 |
+
$registrantArray['custom_field2']['custom_field' . $int]['Answer'] = (trim((string) $item->Answers->Answer));
|
| 3242 |
+
}
|
| 3243 |
+
}
|
| 3244 |
+
if ($parsedReturn->content->Registrant->Costs)
|
| 3245 |
+
{
|
| 3246 |
+
$int = 1;
|
| 3247 |
+
foreach ($parsedReturn->content->Registrant->Costs->Cost as $item)
|
| 3248 |
+
{
|
| 3249 |
+
$int++;
|
| 3250 |
+
$registrantArray['costs']['cost' . $int]['Count'] = (trim((string) $item->Count));
|
| 3251 |
+
$registrantArray['costs']['cost' . $int]['FeeType'] = (trim((string) $item->FeeType));
|
| 3252 |
+
$registrantArray['costs']['cost' . $int]['Rate'] = (trim((string) $item->Rate));
|
| 3253 |
+
$registrantArray['costs']['cost' . $int]['Total'] = (trim((string) $item->Total));
|
| 3254 |
+
|
| 3255 |
+
}
|
| 3256 |
+
}
|
| 3257 |
+
$registrantStruct = new Registrant($registrantArray);
|
| 3258 |
+
return $registrantStruct;
|
| 3259 |
+
}
|
| 3260 |
+
}
|
app/code/local/Rahil/ConstantContact/controllers/SubscriberController.php
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
require("Mage/Newsletter/controllers/SubscriberController.php");
|
| 3 |
+
|
| 4 |
+
class Rahil_Constantcontact_SubscriberController extends Mage_Core_Controller_Front_Action
|
| 5 |
+
{
|
| 6 |
+
|
| 7 |
+
public function indexAction(){
|
| 8 |
+
$model = Mage::getSingleton('constantcontact/list');
|
| 9 |
+
$data = $model->toOptionArray();
|
| 10 |
+
}
|
| 11 |
+
/**
|
| 12 |
+
* New subscription action
|
| 13 |
+
*/
|
| 14 |
+
public function newAction()
|
| 15 |
+
{
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
if ($this->getRequest()->isPost() && $this->getRequest()->getPost('email')) {
|
| 19 |
+
$session = Mage::getSingleton('core/session');
|
| 20 |
+
$customerSession = Mage::getSingleton('customer/session');
|
| 21 |
+
$email = (string) $this->getRequest()->getPost('email');
|
| 22 |
+
|
| 23 |
+
try {
|
| 24 |
+
if (!Zend_Validate::is($email, 'EmailAddress')) {
|
| 25 |
+
Mage::throwException($this->__('Please enter a valid email address.'));
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
if (Mage::getStoreConfig(Mage_Newsletter_Model_Subscriber::XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG) != 1 &&
|
| 29 |
+
!$customerSession->isLoggedIn()) {
|
| 30 |
+
Mage::throwException($this->__('Sorry, but administrator denied subscription for guests. Please <a href="%s">register</a>.', Mage::helper('customer')->getRegisterUrl()));
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
$ownerId = Mage::getModel('customer/customer')
|
| 34 |
+
->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
|
| 35 |
+
->loadByEmail($email)
|
| 36 |
+
->getId();
|
| 37 |
+
if ($ownerId !== null && $ownerId != $customerSession->getId()) {
|
| 38 |
+
Mage::throwException($this->__('This email address is already assigned to another user.'));
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
$status = Mage::getModel('newsletter/subscriber')->subscribe($email);
|
| 42 |
+
|
| 43 |
+
$config = Mage::getStoreConfig('constantcontact');
|
| 44 |
+
if($email!='' && $config['settings']['constant_status']==1){
|
| 45 |
+
$path = Mage::getBaseDir().'/app/code/local/Rahil/ConstantContact/api';
|
| 46 |
+
require_once($path."/ctctWrapper.php");
|
| 47 |
+
|
| 48 |
+
$listObj = new ListsCollection();
|
| 49 |
+
$lists = $listObj->getLists();
|
| 50 |
+
$contactList = array();
|
| 51 |
+
$contactList [] = $config['settings']['constant_list'];
|
| 52 |
+
|
| 53 |
+
$contactObj = new ContactsCollection();
|
| 54 |
+
$cntObj = new Contact(array('email_address'=>$email,'lists'=>$contactList));
|
| 55 |
+
$statusCode = $contactObj->createContact($cntObj);
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
}
|
| 59 |
+
if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
|
| 60 |
+
$session->addSuccess($this->__('Confirmation request has been sent.'));
|
| 61 |
+
}
|
| 62 |
+
else {
|
| 63 |
+
if($config['settings']['constant_status']==1){
|
| 64 |
+
if(isset($statusCode) && $statusCode==201){
|
| 65 |
+
$session->addSuccess($this->__('Thank you for your subscription.'));
|
| 66 |
+
}
|
| 67 |
+
}else{
|
| 68 |
+
$session->addSuccess($this->__('Thank you for your subscription.'));
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
catch (Mage_Core_Exception $e) {
|
| 75 |
+
$session->addException($e, $this->__('There was a problem with the subscription: %s', $e->getMessage()));
|
| 76 |
+
}
|
| 77 |
+
catch (Exception $e) {
|
| 78 |
+
$session->addException($e, $this->__('There was a problem with the subscription.'));
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
$this->_redirectReferer();
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
}
|
app/code/local/Rahil/ConstantContact/etc/config.xml
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Rahil_Constantcontact>
|
| 5 |
+
<version>1.0.3</version>
|
| 6 |
+
</Rahil_Constantcontact>
|
| 7 |
+
</modules>
|
| 8 |
+
<frontend>
|
| 9 |
+
<routers>
|
| 10 |
+
<newsletter>
|
| 11 |
+
<args>
|
| 12 |
+
<modules>
|
| 13 |
+
<Rahil_Constantcontact before="Mage_Newsletter">Rahil_Constantcontact</Rahil_Constantcontact>
|
| 14 |
+
</modules>
|
| 15 |
+
</args>
|
| 16 |
+
</newsletter>
|
| 17 |
+
</routers>
|
| 18 |
+
</frontend>
|
| 19 |
+
|
| 20 |
+
<adminhtml>
|
| 21 |
+
|
| 22 |
+
<acl>
|
| 23 |
+
<resources>
|
| 24 |
+
<all>
|
| 25 |
+
<title>Allow Everything</title>
|
| 26 |
+
</all>
|
| 27 |
+
<admin>
|
| 28 |
+
<children>
|
| 29 |
+
<Rahil_Constantcontact>
|
| 30 |
+
<title>Constantcontact Module</title>
|
| 31 |
+
<sort_order>10</sort_order>
|
| 32 |
+
</Rahil_Constantcontact>
|
| 33 |
+
<system>
|
| 34 |
+
<children>
|
| 35 |
+
<config>
|
| 36 |
+
<children>
|
| 37 |
+
<constantcontact translate="title" module="constantcontact">
|
| 38 |
+
<title>Constantcontact Settings</title>
|
| 39 |
+
<sort_order>50</sort_order>
|
| 40 |
+
</constantcontact>
|
| 41 |
+
</children>
|
| 42 |
+
</config>
|
| 43 |
+
</children>
|
| 44 |
+
</system>
|
| 45 |
+
</children>
|
| 46 |
+
</admin>
|
| 47 |
+
</resources>
|
| 48 |
+
</acl>
|
| 49 |
+
</adminhtml>
|
| 50 |
+
<global>
|
| 51 |
+
<models>
|
| 52 |
+
<constantcontact>
|
| 53 |
+
<class>Rahil_Constantcontact_Model</class>
|
| 54 |
+
</constantcontact>
|
| 55 |
+
</models>
|
| 56 |
+
<helpers>
|
| 57 |
+
<constantcontact>
|
| 58 |
+
<class>Rahil_Constantcontact_Helper</class>
|
| 59 |
+
</constantcontact>
|
| 60 |
+
</helpers>
|
| 61 |
+
</global>
|
| 62 |
+
</config>
|
app/code/local/Rahil/ConstantContact/etc/system.xml
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<sections>
|
| 4 |
+
<constantcontact translate="label" module="constantcontact">
|
| 5 |
+
<label>Constant Contact</label>
|
| 6 |
+
<tab>general</tab>
|
| 7 |
+
<frontend_type>text</frontend_type>
|
| 8 |
+
<sort_order>999</sort_order>
|
| 9 |
+
<show_in_default>1</show_in_default>
|
| 10 |
+
<show_in_website>0</show_in_website>
|
| 11 |
+
<show_in_store>0</show_in_store>
|
| 12 |
+
<groups>
|
| 13 |
+
<settings translate="label">
|
| 14 |
+
<label>Constant Contact Settings</label>
|
| 15 |
+
<frontend_type>text</frontend_type>
|
| 16 |
+
<sort_order>1</sort_order>
|
| 17 |
+
<show_in_default>1</show_in_default>
|
| 18 |
+
<show_in_website>0</show_in_website>
|
| 19 |
+
<show_in_store>0</show_in_store>
|
| 20 |
+
<fields>
|
| 21 |
+
<constant_api_key translate="label, comment">
|
| 22 |
+
<label>Constant API Key</label>
|
| 23 |
+
<frontend_type>text</frontend_type>
|
| 24 |
+
<sort_order>2</sort_order>
|
| 25 |
+
<show_in_default>1</show_in_default>
|
| 26 |
+
<show_in_website>0</show_in_website>
|
| 27 |
+
<show_in_store>0</show_in_store>
|
| 28 |
+
</constant_api_key>
|
| 29 |
+
<constant_username translate="label, comment">
|
| 30 |
+
<label>Constant UserName</label>
|
| 31 |
+
<frontend_type>text</frontend_type>
|
| 32 |
+
<sort_order>3</sort_order>
|
| 33 |
+
<show_in_default>1</show_in_default>
|
| 34 |
+
<show_in_website>0</show_in_website>
|
| 35 |
+
<show_in_store>0</show_in_store>
|
| 36 |
+
</constant_username>
|
| 37 |
+
<constant_password translate="label, comment">
|
| 38 |
+
<label>Constant Password</label>
|
| 39 |
+
<frontend_type>password</frontend_type>
|
| 40 |
+
<sort_order>4</sort_order>
|
| 41 |
+
<show_in_default>1</show_in_default>
|
| 42 |
+
<show_in_website>0</show_in_website>
|
| 43 |
+
<show_in_store>0</show_in_store>
|
| 44 |
+
</constant_password>
|
| 45 |
+
|
| 46 |
+
<constant_status translate="label">
|
| 47 |
+
<label>Enabled</label>
|
| 48 |
+
<frontend_type>select</frontend_type>
|
| 49 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 50 |
+
<sort_order>6</sort_order>
|
| 51 |
+
<show_in_default>1</show_in_default>
|
| 52 |
+
<show_in_website>1</show_in_website>
|
| 53 |
+
<show_in_store>1</show_in_store>
|
| 54 |
+
</constant_status>
|
| 55 |
+
|
| 56 |
+
<constant_list translate="label">
|
| 57 |
+
<label>Contact List</label>
|
| 58 |
+
<frontend_type>select</frontend_type>
|
| 59 |
+
<source_model>constantcontact/list</source_model>
|
| 60 |
+
<sort_order>6</sort_order>
|
| 61 |
+
<show_in_default>1</show_in_default>
|
| 62 |
+
<show_in_website>1</show_in_website>
|
| 63 |
+
<show_in_store>1</show_in_store>
|
| 64 |
+
</constant_list>
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
</fields>
|
| 71 |
+
</settings>
|
| 72 |
+
</groups>
|
| 73 |
+
</constantcontact>
|
| 74 |
+
</sections>
|
| 75 |
+
</config>
|
app/etc/modules/Rahil_Constantcontact.xml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Plumtree_Constantcontact>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>local</codePool>
|
| 7 |
+
</Plumtree_Constantcontact>
|
| 8 |
+
</modules>
|
| 9 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>Constant_Contact</name>
|
| 4 |
+
<version>1.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license>GNU</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>Constant Contact Magento Extension</summary>
|
| 10 |
+
<description>Constant contact magento extension will automatically add magento newsletter subscribers to your constant contact list.
|
| 11 |
+
|
| 12 |
+
you can select contact list from system > configuration > constant contact. to add newsletter email to constant contact</description>
|
| 13 |
+
<notes>You must have an account with constant contact.
|
| 14 |
+
and you need to enter your constant contact api key in configuration section.</notes>
|
| 15 |
+
<authors><author><name>Rahil</name><user>auto-converted</user><email>rahil@hirephpwebdeveloper.com</email></author></authors>
|
| 16 |
+
<date>2011-01-21</date>
|
| 17 |
+
<time>07:07:58</time>
|
| 18 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Rahil_Constantcontact.xml" hash="47c738c987ef8d64fc5eca9e630fa22e"/></dir></target><target name="magelocal"><dir name="Rahil"><dir name="ConstantContact"><dir name="api"><file name="ctctWrapper.php" hash="23853c580c26772b82842400255424a0"/></dir><dir name="controllers"><file name="SubscriberController.php" hash="af0ca956af74904f61090f6c4a938a87"/></dir><dir name="etc"><file name="config.xml" hash="8c121dce1ba364364cebb4991eae8808"/><file name="system.xml" hash="1b6ccd93b8be94568fd13baea2cd0247"/></dir><dir name="Helper"><file name="Data.php" hash="5b6d7d2fc1234213c7f0d3088c8832aa"/></dir><dir name="Model"><file name="Constantcontact.php" hash="456f4085ec5b261f6c5b5c1bbe6fcc01"/><file name="List.php" hash="27cb17e4a598a5b93623a67d3fc5f577"/></dir></dir></dir></target></contents>
|
| 19 |
+
<compatible/>
|
| 20 |
+
<dependencies/>
|
| 21 |
+
</package>
|
