Overview

Namespaces

  • Ctct
    • Auth
    • Components
      • Account
      • Activities
      • Contacts
      • EmailMarketing
      • Library
      • Tracking
    • Exceptions
    • Services
    • Util
    • WebHooks

Classes

  • Ctct\Auth\CtctOAuth2
  • Ctct\Auth\SessionDataStore
  • Ctct\Components\Account\AccountInfo
  • Ctct\Components\Account\VerifiedEmailAddress
  • Ctct\Components\Activities\Activity
  • Ctct\Components\Activities\ActivityError
  • Ctct\Components\Activities\AddContacts
  • Ctct\Components\Activities\AddContactsImportData
  • Ctct\Components\Activities\ExportContacts
  • Ctct\Components\Component
  • Ctct\Components\Contacts\Address
  • Ctct\Components\Contacts\Contact
  • Ctct\Components\Contacts\ContactList
  • Ctct\Components\Contacts\CustomField
  • Ctct\Components\Contacts\EmailAddress
  • Ctct\Components\Contacts\Note
  • Ctct\Components\EmailMarketing\Campaign
  • Ctct\Components\EmailMarketing\ClickThroughDetails
  • Ctct\Components\EmailMarketing\MessageFooter
  • Ctct\Components\EmailMarketing\Schedule
  • Ctct\Components\EmailMarketing\TestSend
  • Ctct\Components\Library\File
  • Ctct\Components\Library\FileUploadStatus
  • Ctct\Components\Library\Folder
  • Ctct\Components\Library\Thumbnail
  • Ctct\Components\ResultSet
  • Ctct\Components\Tracking\BounceActivity
  • Ctct\Components\Tracking\ClickActivity
  • Ctct\Components\Tracking\ForwardActivity
  • Ctct\Components\Tracking\OpenActivity
  • Ctct\Components\Tracking\SendActivity
  • Ctct\Components\Tracking\TrackingActivity
  • Ctct\Components\Tracking\TrackingSummary
  • Ctct\Components\Tracking\UnsubscribeActivity
  • Ctct\ConstantContact
  • Ctct\Services\AccountService
  • Ctct\Services\ActivityService
  • Ctct\Services\BaseService
  • Ctct\Services\CampaignScheduleService
  • Ctct\Services\CampaignTrackingService
  • Ctct\Services\ContactService
  • Ctct\Services\ContactTrackingService
  • Ctct\Services\EmailMarketingService
  • Ctct\Services\LibraryService
  • Ctct\Services\ListService
  • Ctct\SplClassLoader
  • Ctct\Util\Config
  • Ctct\WebHooks\CTCTWebhookUtil

Interfaces

  • Ctct\Auth\CtctDataStore

Exceptions

  • Ctct\Exceptions\CtctException
  • Ctct\Exceptions\IllegalArgumentException
  • Ctct\Exceptions\OAuth2Exception
  • Overview
  • Namespace
  • Class
  1: <?php
  2: namespace Ctct\Services;
  3: 
  4: use Ctct\Exceptions\CtctException;
  5: use Ctct\Util\Config;
  6: use Ctct\Components\Tracking\BounceActivity;
  7: use Ctct\Components\Tracking\ClickActivity;
  8: use Ctct\Components\Tracking\ForwardActivity;
  9: use Ctct\Components\Tracking\OpenActivity;
 10: use Ctct\Components\Tracking\UnsubscribeActivity;
 11: use Ctct\Components\Tracking\SendActivity;
 12: use Ctct\Components\Tracking\TrackingSummary;
 13: use Ctct\Components\ResultSet;
 14: use GuzzleHttp\Exception\ClientException;
 15: 
 16: /**
 17:  * Performs all actions pertaining to Contact Tracking
 18:  *
 19:  * @package Services
 20:  * @author Constant Contact
 21:  */
 22: class ContactTrackingService extends BaseService
 23: {
 24:     /**
 25:      * Get bounces for a given contact
 26:      * @param string $accessToken - Constant Contact OAuth2 access token
 27:      * @param string $contactId - Contact id
 28:      * @param array $params - associative array of query parameters and values to append to the request.
 29:      *      Allowed parameters include:
 30:      *      limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
 31:      *      created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
 32:      *      next - the next link returned from a previous paginated call. May only be used by itself.
 33:      * @return ResultSet - Containing a results array of {@link BounceActivity}
 34:      * @throws CtctException
 35:      */
 36:     public function getBounces($accessToken, $contactId, Array $params = array())
 37:     {
 38:         $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.contact_tracking_bounces'), $contactId);
 39: 
 40:         $request = parent::createBaseRequest($accessToken, 'GET', $baseUrl);
 41:         if ($params) {
 42:             $query = $request->getQuery();
 43:             foreach ($params as $name => $value) {
 44:                 $query->add($name, $value);
 45:             }
 46:         }
 47: 
 48:         try {
 49:             $response = parent::getClient()->send($request);
 50:         } catch (ClientException $e) {
 51:             throw parent::convertException($e);
 52:         }
 53: 
 54:         $body = $response->json();
 55:         $bounces = array();
 56:         foreach ($body['results'] as $bounceActivity) {
 57:             $bounces[] = BounceActivity::create($bounceActivity);
 58:         }
 59: 
 60:         return new ResultSet($bounces, $body['meta']);
 61:     }
 62: 
 63:     /**
 64:      * Get clicks for a given contact
 65:      * @param string $accessToken - Constant Contact OAuth2 access token
 66:      * @param string $contactId - Contact id
 67:      * @param array $params - associative array of query parameters and values to append to the request.
 68:      *      Allowed parameters include:
 69:      *      limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
 70:      *      created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
 71:      *      next - the next link returned from a previous paginated call. May only be used by itself.
 72:      * @return ResultSet - Containing a results array of {@link ClickActivity}
 73:      * @throws CtctException
 74:      */
 75:     public function getClicks($accessToken, $contactId, Array $params = array())
 76:     {
 77:         $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.contact_tracking_clicks'), $contactId);
 78: 
 79:         $request = parent::createBaseRequest($accessToken, 'GET', $baseUrl);
 80:         if ($params) {
 81:             $query = $request->getQuery();
 82:             foreach ($params as $name => $value) {
 83:                 $query->add($name, $value);
 84:             }
 85:         }
 86: 
 87:         try {
 88:             $response = parent::getClient()->send($request);
 89:         } catch (ClientException $e) {
 90:             throw parent::convertException($e);
 91:         }
 92: 
 93:         $body = $response->json();
 94:         $clicks = array();
 95:         foreach ($body['results'] as $click_activity) {
 96:             $clicks[] = ClickActivity::create($click_activity);
 97:         }
 98: 
 99:         return new ResultSet($clicks, $body['meta']);
100:     }
101: 
102:     /**
103:      * Get forwards for a given contact
104:      * @param string $accessToken - Constant Contact OAuth2 access token
105:      * @param string $contactId - Contact id
106:      * @param array $params - associative array of query parameters and values to append to the request.
107:      *      Allowed parameters include:
108:      *      limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
109:      *      created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
110:      *      next - the next link returned from a previous paginated call. May only be used by itself.
111:      * @return ResultSet - Containing a results array of {@link ForwardActivity}
112:      * @throws CtctException
113:      */
114:     public function getForwards($accessToken, $contactId, Array $params = array())
115:     {
116:         $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.contact_tracking_forwards'), $contactId);
117: 
118:         $request = parent::createBaseRequest($accessToken, 'GET', $baseUrl);
119:         if ($params) {
120:             $query = $request->getQuery();
121:             foreach ($params as $name => $value) {
122:                 $query->add($name, $value);
123:             }
124:         }
125: 
126:         try {
127:             $response = parent::getClient()->send($request);
128:         } catch (ClientException $e) {
129:             throw parent::convertException($e);
130:         }
131: 
132:         $body = $response->json();
133:         $forwards = array();
134:         foreach ($body['results'] as $forward_activity) {
135:             $forwards[] = ForwardActivity::create($forward_activity);
136:         }
137: 
138:         return new ResultSet($forwards, $body['meta']);
139:     }
140: 
141:     /**
142:      * Get opens for a given contact
143:      * @param string $accessToken - Constant Contact OAuth2 access token
144:      * @param string $contactId - Contact id
145:      * @param array $params - associative array of query parameters and values to append to the request.
146:      *      Allowed parameters include:
147:      *      limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
148:      *      created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
149:      *      next - the next link returned from a previous paginated call. May only be used by itself.
150:      * @return ResultSet - Containing a results array of {@link OpenActivity}
151:      * @throws CtctException
152:      */
153:     public function getOpens($accessToken, $contactId, Array $params = array())
154:     {
155:         $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.contact_tracking_opens'), $contactId);
156: 
157:         $request = parent::createBaseRequest($accessToken, 'GET', $baseUrl);
158:         if ($params) {
159:             $query = $request->getQuery();
160:             foreach ($params as $name => $value) {
161:                 $query->add($name, $value);
162:             }
163:         }
164: 
165:         try {
166:             $response = parent::getClient()->send($request);
167:         } catch (ClientException $e) {
168:             throw parent::convertException($e);
169:         }
170: 
171:         $body = $response->json();
172:         $opens = array();
173:         foreach ($body['results'] as $open_activity) {
174:             $opens[] = OpenActivity::create($open_activity);
175:         }
176: 
177:         return new ResultSet($opens, $body['meta']);
178:     }
179: 
180:     /**
181:      * Get sends for a given contact
182:      * @param string $accessToken - Constant Contact OAuth2 access token
183:      * @param string $contactId - Contact id
184:      * @param array $params - associative array of query parameters and values to append to the request.
185:      *      Allowed parameters include:
186:      *      limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
187:      *      created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
188:      *      next - the next link returned from a previous paginated call. May only be used by itself.
189:      * @return ResultSet - Containing a results array of {@link SendActivity}
190:      * @throws CtctException
191:      */
192:     public function getSends($accessToken, $contactId, Array $params = array())
193:     {
194:         $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.contact_tracking_sends'), $contactId);
195: 
196:         $request = parent::createBaseRequest($accessToken, 'GET', $baseUrl);
197:         if ($params) {
198:             $query = $request->getQuery();
199:             foreach ($params as $name => $value) {
200:                 $query->add($name, $value);
201:             }
202:         }
203: 
204:         try {
205:             $response = parent::getClient()->send($request);
206:         } catch (ClientException $e) {
207:             throw parent::convertException($e);
208:         }
209: 
210:         $body = $response->json();
211:         $sends = array();
212:         foreach ($body['results'] as $send_activity) {
213:             $sends[] = SendActivity::create($send_activity);
214:         }
215: 
216:         return new ResultSet($sends, $body['meta']);
217:     }
218: 
219:     /**
220:      * Get unsubscribes for a given contact
221:      * @param string $accessToken - Constant Contact OAuth2 access token
222:      * @param string $contactId - Contact id
223:      * @param array $params - associative array of query parameters and values to append to the request.
224:      *      Allowed parameters include:
225:      *      limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
226:      *      created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
227:      *      next - the next link returned from a previous paginated call. May only be used by itself.
228:      * @return ResultSet - Containing a results array of {@link UnsubscribeActivity}
229:      * @throws CtctException
230:      */
231:     public function getUnsubscribes($accessToken, $contactId, Array $params = array())
232:     {
233:         $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.contact_tracking_unsubscribes'), $contactId);
234: 
235:         $request = parent::createBaseRequest($accessToken, 'GET', $baseUrl);
236:         if ($params) {
237:             $query = $request->getQuery();
238:             foreach ($params as $name => $value) {
239:                 $query->add($name, $value);
240:             }
241:         }
242: 
243:         try {
244:             $response = parent::getClient()->send($request);
245:         } catch (ClientException $e) {
246:             throw parent::convertException($e);
247:         }
248: 
249:         $body = $response->json();
250:         $opt_outs = array();
251:         foreach ($body['results'] as $opt_out_activity) {
252:             $opt_outs[] = UnsubscribeActivity::create($opt_out_activity);
253:         }
254: 
255:         return new ResultSet($opt_outs, $body['meta']);
256:     }
257: 
258:     /**
259:      * Get a summary of reporting data for a given contact
260:      * @param string $accessToken - Constant Contact OAuth2 access token
261:      * @param string $contactId - Contact id
262:      * @return TrackingSummary
263:      * @throws CtctException
264:      */
265:     public function getSummary($accessToken, $contactId)
266:     {
267:         $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.contact_tracking_summary'), $contactId);
268: 
269:         $request = parent::createBaseRequest($accessToken, 'GET', $baseUrl);
270: 
271:         try {
272:             $response = parent::getClient()->send($request);
273:         } catch (ClientException $e) {
274:             throw parent::convertException($e);
275:         }
276: 
277:         return TrackingSummary::create($response->json());
278:     }
279: }
280: 
API documentation generated by ApiGen