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