├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── HISTORY.md ├── LICENSE ├── README.md ├── RELEASE.md ├── class ├── base_classes.php ├── cacert.pem ├── exceptions.php ├── log.php ├── serialisation.php ├── services_json.php └── transport.php ├── composer.json ├── composer.lock ├── csrest_administrators.php ├── csrest_campaigns.php ├── csrest_clients.php ├── csrest_events.php ├── csrest_general.php ├── csrest_journey_emails.php ├── csrest_journeys.php ├── csrest_lists.php ├── csrest_people.php ├── csrest_segments.php ├── csrest_subscribers.php ├── csrest_templates.php ├── csrest_transactional_classicemail.php ├── csrest_transactional_smartemail.php ├── csrest_transactional_timeline.php ├── samples ├── authentication │ ├── auth_with_api_key.php │ ├── auth_with_oauth.php │ ├── exchange_token.php │ ├── get_authorize_url.php │ └── refresh_token.php ├── campaign │ ├── create.php │ ├── create_from_template.php │ ├── delete.php │ ├── get_bounces.php │ ├── get_clicks.php │ ├── get_email_client_usage.php │ ├── get_lists_and_segments.php │ ├── get_opens.php │ ├── get_recipients.php │ ├── get_spam.php │ ├── get_summary.php │ ├── get_unsubscribes.php │ ├── send.php │ ├── send_preview.php │ └── unschedule.php ├── client │ ├── create.php │ ├── delete.php │ ├── get.php │ ├── get_campaigns.php │ ├── get_drafts.php │ ├── get_journeys.php │ ├── get_lists.php │ ├── get_lists_for_email.php │ ├── get_scheduled.php │ ├── get_segments.php │ ├── get_suppressionlist.php │ ├── get_tags.php │ ├── get_templates.php │ ├── set_basics.php │ ├── set_monthly_billing.php │ ├── set_payg_billing.php │ ├── suppress.php │ ├── transfer_credits.php │ └── unsuppress.php ├── events │ └── event_track.php ├── external_session_url.php ├── get_apikey.php ├── get_billing_details.php ├── get_clients.php ├── get_countries.php ├── get_systemdate.php ├── get_timezones.php ├── journeys │ ├── get_journey_bounces.php │ ├── get_journey_clicks.php │ ├── get_journey_opens.php │ ├── get_journey_recipients.php │ ├── get_journey_summary.php │ └── get_journey_unsubscribes.php ├── list │ ├── activate_webhook.php │ ├── create.php │ ├── create_custom_field.php │ ├── create_webhook.php │ ├── deactivate_webhook.php │ ├── delete.php │ ├── delete_custom_field.php │ ├── delete_webhook.php │ ├── get.php │ ├── get_active_subscribers.php │ ├── get_bounced_subscribers.php │ ├── get_custom_fields.php │ ├── get_deleted_subscribers.php │ ├── get_segments.php │ ├── get_stats.php │ ├── get_unconfirmed_subscribers.php │ ├── get_unsubscribed_subscribers.php │ ├── get_webhooks.php │ ├── list_webhook_receiver.php │ ├── test_webhook.php │ ├── update.php │ ├── update_custom_field.php │ └── update_field_options.php ├── segment │ ├── add_rule.php │ ├── clear_rules.php │ ├── create.php │ ├── delete.php │ ├── get.php │ ├── get_subscribers.php │ └── update.php ├── subscriber │ ├── add.php │ ├── delete.php │ ├── get.php │ ├── get_history.php │ ├── import.php │ ├── unsubscribe.php │ └── update.php ├── template │ ├── create.php │ ├── delete.php │ ├── get.php │ └── update.php └── transactional │ ├── classic_groups.php │ ├── classic_send.php │ ├── smart_details.php │ ├── smart_list.php │ ├── smart_send.php │ └── timeline.php └── tests ├── all_tests.php ├── class_tests ├── response_tests.php └── transport_test.php ├── csrest_administrators_test.php ├── csrest_campaigns_test.php ├── csrest_clients_test.php ├── csrest_events_test.php ├── csrest_journey_emails_test.php ├── csrest_journeys_test.php ├── csrest_lists_test.php ├── csrest_people_test.php ├── csrest_segments_test.php ├── csrest_subscribers_test.php ├── csrest_template_test.php ├── csrest_test.php └── responses ├── active_subscribers.json ├── add_subscriber.json ├── apikey.json ├── bounced_subscribers.json ├── campaign_bounces.json ├── campaign_clicks.json ├── campaign_listsandsegments.json ├── campaign_opens.json ├── campaign_recipients.json ├── campaign_spam.json ├── campaign_summary.json ├── campaign_unsubscribes.json ├── campaigns.json ├── client_details.json ├── clients.json ├── countries.json ├── create_campaign.json ├── create_client.json ├── create_custom_field.json ├── create_list.json ├── create_list_webhook.json ├── create_segment.json ├── create_template.json ├── custom_api_error.json ├── custom_fields.json ├── deleted_subscribers.json ├── drafts.json ├── import_subscribers.json ├── import_subscribers_partial_success.json ├── journey_details.json ├── journeys.json ├── list_details.json ├── list_stats.json ├── list_webhooks.json ├── lists.json ├── listsforemail.json ├── oauth_exchange_token.json ├── scheduled.json ├── segment_details.json ├── segment_subscribers.json ├── segments.json ├── subscriber_details.json ├── subscriber_history.json ├── suppressionlist.json ├── systemdate.json ├── tags.json ├── template_details.json ├── templates.json ├── timezones.json ├── unconfirmed_subscribers.json └── unsubscribed_subscribers.json /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .buildpath 3 | .project 4 | .settings/ 5 | working-samples/ 6 | vendor/ 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | matrix: 4 | include: 5 | - php: 5.3 6 | dist: precise 7 | - php: 5.4 8 | dist: trusty 9 | - php: 5.5 10 | dist: trusty 11 | - php: 5.6 12 | - php: 7.0 13 | - php: 7.1 14 | - php: 7.2 15 | - php: 7.3 16 | - php: 7.4 17 | - php: hhvm-3.30 18 | 19 | before_script: composer install --dev 20 | script: cd tests && php all_tests.php && cd .. 21 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Guidelines for contributing 2 | 3 | 1. [Fork the repository](https://help.github.com/articles/fork-a-repo). 4 | 2. [Create a topic branch](http://learn.github.com/p/branching.html). 5 | 3. Make your changes, including tests for your changes. 6 | 4. Ensure that all tests pass, by running: 7 | 8 | ``` 9 | composer install --dev 10 | cd tests && php all_tests.php && cd .. 11 | ``` 12 | 13 | The [Travis CI build](https://travis-ci.org/campaignmonitor/createsend-php) runs on PHP `5.3` and `5.4`. 14 | 15 | 5. It should go without saying, but do not increment the version number in your commits. 16 | 6. [Submit a pull request](https://help.github.com/articles/using-pull-requests). 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010 Toby Brain 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | 21 | ------------------------------------------------------------------------------ 22 | For Services_JSON Library (classes/services_json.php) 23 | ------------------------------------------------------------------------------ 24 | Redistribution and use in source and binary forms, with or 25 | without modification, are permitted provided that the following 26 | conditions are met: Redistributions of source code must retain the 27 | above copyright notice, this list of conditions and the following 28 | disclaimer. Redistributions in binary form must reproduce the above 29 | copyright notice, this list of conditions and the following disclaimer 30 | in the documentation and/or other materials provided with the 31 | distribution. 32 | 33 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 34 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 35 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 36 | NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 37 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 38 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 39 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 40 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 41 | TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 42 | USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 43 | DAMAGE. 44 | Author: Michal Migurski 45 | Author: Matt Knapp 46 | Author: Brett Stimmerman 47 | Copyright (c) 2005 Michal Migurski 48 | http://www.opensource.org/licenses/bsd-license.php 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # createsend [![Build Status](https://app.travis-ci.com/campaignmonitor/createsend-php.svg?branch=master)](https://app.travis-ci.com/campaignmonitor/createsend-php) 2 | A PHP library which implements the complete functionality of the [Campaign Monitor API](http://www.campaignmonitor.com/api/). 3 | 4 | ## Installation 5 | 6 | ### Composer 7 | If you use [Composer](http://getcomposer.org/), you can run the following command from the root of your project: 8 | 9 | ``` 10 | composer require campaignmonitor/createsend-php 11 | ``` 12 | 13 | Or add [campaignmonitor/createsend-php](https://packagist.org/packages/campaignmonitor/createsend-php) to your `composer.json` file: 14 | 15 | ```json 16 | { 17 | "require": { 18 | "campaignmonitor/createsend-php": "{version}" 19 | } 20 | } 21 | ``` 22 | 23 | Followed by running: 24 | 25 | ``` 26 | composer update 27 | ``` 28 | 29 | ### Manual Installation 30 | Otherwise you can simply [download](https://github.com/campaignmonitor/createsend-php/tags) the library and include it in your project. 31 | 32 | After you have installed the library, simply include the relevant API class, as follows: 33 | 34 | ```php 35 | require_once 'csrest_campaigns.php' 36 | ``` 37 | 38 | ## Authenticating 39 | 40 | The Campaign Monitor API supports authentication using either OAuth or an API key. 41 | 42 | ### Using OAuth 43 | 44 | Depending on the environment you are developing in, you may wish to use a PHP OAuth library to get access tokens for your users. If you don't use an OAuth library, you will need to get access tokens for your users by following the instructions included in the Campaign Monitor API [documentation](http://www.campaignmonitor.com/api/getting-started/#authenticating_with_oauth). This package provides functionality to help you do this, as described below. You may also wish to reference this [example application](https://gist.github.com/jdennes/4973318), which is implemented using [Slim](http://slimframework.com/) but could easily be adapted for use with any PHP framework. 45 | 46 | The first thing your application should do is redirect your user to the Campaign Monitor authorization URL where they will have the opportunity to approve your application to access their Campaign Monitor account. You can get this authorization URL by using the `CS_REST_General::authorize_url()` method, like so: 47 | 48 | ```php 49 | require_once 'csrest_general.php'; 50 | 51 | $authorize_url = CS_REST_General::authorize_url( 52 | 'Client ID for your application', 53 | 'Redirect URI for your application', 54 | 'The permission level your application requires', 55 | 'Optional state data to be included' 56 | ); 57 | # Redirect your users to $authorize_url. 58 | ``` 59 | 60 | If your user approves your application, they will then be redirected to the `redirect_uri` you specified, which will include a `code` parameter, and optionally a `state` parameter in the query string. Your application should implement a handler which can exchange the code passed to it for an access token, using `CS_REST_General::exchange_token()` like so: 61 | 62 | ```php 63 | require_once 'csrest_general.php'; 64 | 65 | $result = CS_REST_General::exchange_token( 66 | 'Client ID for your application', 67 | 'Client Secret for your application', 68 | 'Redirect URI for your application', 69 | 'A unique code for your user' # Get the code parameter from the query string 70 | ); 71 | 72 | if ($result->was_successful()) { 73 | $access_token = $result->response->access_token; 74 | $expires_in = $result->response->expires_in; 75 | $refresh_token = $result->response->refresh_token; 76 | # Save $access_token, $expires_in, and $refresh_token. 77 | } else { 78 | echo 'An error occurred:\n'; 79 | echo $result->response->error.': '.$result->response->error_description."\n"; 80 | # Handle error... 81 | } 82 | ``` 83 | 84 | At this point you have an access token and refresh token for your user which you should store somewhere convenient so that your application can look up these values when your user wants to make future Campaign Monitor API calls. 85 | 86 | Once you have an access token and refresh token for your user, you can authenticate and make further API calls like so: 87 | 88 | ```php 89 | require_once 'csrest_general.php'; 90 | 91 | $auth = array( 92 | 'access_token' => 'your access token', 93 | 'refresh_token' => 'your refresh_token'); 94 | $wrap = new CS_REST_General($auth); 95 | 96 | $result = $wrap->get_clients(); 97 | var_dump($result->response); 98 | ``` 99 | 100 | All OAuth tokens have an expiry time, and can be renewed with a corresponding refresh token. If your access token expires when attempting to make an API call, you will receive an error response, so your code should handle this. Here's an example of how you could do this: 101 | 102 | ```php 103 | require_once 'csrest_general.php'; 104 | 105 | $auth = array( 106 | 'access_token' => 'your access token', 107 | 'refresh_token' => 'your refresh token' 108 | ); 109 | $wrap = new CS_REST_General($auth); 110 | $result = $wrap->get_clients(); 111 | if (!$result->was_successful()) { 112 | # If you receive '121: Expired OAuth Token', refresh the access token 113 | if ($result->response->Code == 121) { 114 | list($new_access_token, $new_expires_in, $new_refresh_token) = 115 | $wrap->refresh_token(); 116 | # Save $new_access_token, $new_expires_in, and $new_refresh_token 117 | } 118 | # Make the call again 119 | $result = $wrap->get_clients(); 120 | } 121 | var_dump($result->response); 122 | ``` 123 | 124 | ### Using an API key 125 | 126 | ```php 127 | require_once 'csrest_general.php'; 128 | 129 | $auth = array('api_key' => 'your API key'); 130 | $wrap = new CS_REST_General($auth); 131 | 132 | $result = $wrap->get_clients(); 133 | var_dump($result->response); 134 | ``` 135 | ## API Call Timeout 136 | You can set your local API call timeout time in createsend-php\class\transport.php line 11, in the CS_REST_CALL_TIMEOUT variable. Currently the default is 120 secs. 137 | 138 | ## Examples 139 | 140 | Samples for creating or accessing all resources can be found in the samples directory. 141 | These samples can be used as the basis for your own application and provide an outline of 142 | the expected inputs for each API call. 143 | 144 | Further documentation of the inputs and outputs of each call can be found in the 145 | documentation in each of the csrest_*.php files or simply by examining the 146 | var_dump results in each of the provided samples. 147 | 148 | ## Contributing 149 | 150 | Please check the [guidelines for contributing](https://github.com/campaignmonitor/createsend-php/blob/master/CONTRIBUTING.md) to this repository. 151 | 152 | ## Releasing 153 | 154 | Please check the [instructions for releasing](https://github.com/campaignmonitor/createsend-php/blob/master/RELEASE.md) this library. 155 | -------------------------------------------------------------------------------- /RELEASE.md: -------------------------------------------------------------------------------- 1 | # Releasing createsend-php 2 | 3 | ## Requirements 4 | 5 | - You must have [Composer](https://getcomposer.org/) installed. 6 | 7 | ## Prepare the release 8 | 9 | - Increment the `CS_REST_WRAPPER_VERSION` constant in the `class/base_classes.php` file, ensuring that you use [Semantic Versioning](http://semver.org/). 10 | - Add an entry to `HISTORY.md` which clearly explains the new release. 11 | - Install development dependencies and ensure that tests pass locally: 12 | 13 | ``` 14 | composer install --dev 15 | cd tests && php all_tests.php && cd .. 16 | ``` 17 | 18 | - Commit your changes: 19 | 20 | ``` 21 | git commit -am "Version X.Y.Z" 22 | ``` 23 | 24 | - Tag the new version: 25 | 26 | ``` 27 | git tag -a vX.Y.Z -m "Version X.Y.Z" 28 | ``` 29 | 30 | - Push your changes to GitHub, including the tag you just created: 31 | 32 | ``` 33 | git push origin master --tags 34 | ``` 35 | 36 | - Ensure that all [tests](https://travis-ci.org/campaignmonitor/createsend-php) pass. 37 | 38 | ## Release the module 39 | 40 | There is a [GitHub service hook](https://github.com/campaignmonitor/createsend-php/settings/hooks) for the [Packagist](https://packagist.org/) PHP package repository, which is configured to update the [createsend-php](https://packagist.org/packages/campaignmonitor/createsend-php) package when new tags are pushed to GitHub. 41 | 42 | So there are no further steps to releasing the module. You should now see the latest version of the module listed on [Packagist](https://packagist.org/packages/campaignmonitor/createsend-php). All done! 43 | -------------------------------------------------------------------------------- /class/exceptions.php: -------------------------------------------------------------------------------- 1 | _level = $level; 13 | } 14 | 15 | function log_message($message, $module, $level) { 16 | if($this->_level >= $level) { 17 | echo date('G:i:s').' - '.$module.': '.$message."
\n"; 18 | } 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /class/serialisation.php: -------------------------------------------------------------------------------- 1 | log_message('Getting serialiser', __FUNCTION__, CS_REST_LOG_VERBOSE); 6 | if(function_exists('json_decode') && function_exists('json_encode')) { 7 | return new CS_REST_NativeJsonSerialiser($log); 8 | } else { 9 | return new CS_REST_ServicesJsonSerialiser($log); 10 | } 11 | } 12 | } 13 | 14 | if (!class_exists('CS_REST_BaseSerialiser')) { 15 | class CS_REST_BaseSerialiser { 16 | 17 | var $_log; 18 | 19 | function __construct($log) { 20 | $this->_log = $log; 21 | } 22 | 23 | /** 24 | * Recursively ensures that all data values are utf-8 encoded. 25 | * @param array $data All values of this array are checked for utf-8 encoding. 26 | */ 27 | function check_encoding($data) { 28 | 29 | foreach($data as $k => $v) { 30 | // If the element is a sub-array then recusively encode the array 31 | if(is_array($v)) { 32 | $data[$k] = $this->check_encoding($v); 33 | // Otherwise if the element is a string then we need to check the encoding 34 | } else if(is_string($v)) { 35 | if((function_exists('mb_detect_encoding') && mb_detect_encoding($v) !== 'UTF-8') || 36 | (function_exists('mb_check_encoding') && !mb_check_encoding($v, 'UTF-8'))) { 37 | // The string is using some other encoding, make sure we utf-8 encode 38 | $v = mb_convert_encoding($v, 'UTF-8', 'ISO-8859-1'); 39 | } 40 | 41 | $data[$k] = $v; 42 | } 43 | } 44 | 45 | return $data; 46 | } 47 | } 48 | } 49 | 50 | if (!class_exists('CS_REST_DoNothingSerialiser')) { 51 | class CS_REST_DoNothingSerialiser extends CS_REST_BaseSerialiser { 52 | function __construct() {} 53 | function get_type() { return 'do_nothing'; } 54 | function serialise($data) { return $data; } 55 | function deserialise($text) { 56 | $data = json_decode($text); 57 | return is_null($data) ? $text : $data; 58 | } 59 | function check_encoding($data) { return $data; } 60 | } 61 | } 62 | 63 | if (!class_exists('CS_REST_NativeJsonSerialiser')) { 64 | class CS_REST_NativeJsonSerialiser extends CS_REST_BaseSerialiser { 65 | 66 | function get_format() { 67 | return 'json'; 68 | } 69 | 70 | function get_type() { 71 | return 'native'; 72 | } 73 | 74 | function serialise($data) { 75 | if(is_null($data) || $data == '') return ''; 76 | return json_encode($this->check_encoding($data)); 77 | } 78 | 79 | function deserialise($text) { 80 | $data = json_decode($text); 81 | 82 | return $this->strip_surrounding_quotes(is_null($data) ? $text : $data); 83 | } 84 | 85 | /** 86 | * We've had sporadic reports of people getting ID's from create routes with the surrounding quotes present. 87 | * There is no case where these should be present. Just get rid of it. 88 | */ 89 | function strip_surrounding_quotes($data) { 90 | if(is_string($data)) { 91 | return trim($data, '"'); 92 | } 93 | 94 | return $data; 95 | } 96 | } 97 | } 98 | 99 | if (!class_exists('CS_REST_ServicesJsonSerialiser')) { 100 | class CS_REST_ServicesJsonSerialiser extends CS_REST_BaseSerialiser { 101 | 102 | var $_serialiser; 103 | 104 | function __construct($log) { 105 | parent::__construct($log); 106 | if (!class_exists('Services_JSON', false)) { 107 | require_once dirname(__FILE__).'/services_json.php'; 108 | } 109 | 110 | $this->_serialiser = new Services_JSON(); 111 | } 112 | 113 | function get_content_type() { 114 | return 'application/json'; 115 | } 116 | 117 | function get_format() { 118 | return 'json'; 119 | } 120 | 121 | function get_type() { 122 | return 'services_json'; 123 | } 124 | 125 | function serialise($data) { 126 | if(is_null($data) || $data == '') return ''; 127 | return $this->_serialiser->encode($this->check_encoding($data)); 128 | } 129 | 130 | function deserialise($text) { 131 | $data = $this->_serialiser->decode($text); 132 | 133 | return is_null($data) ? $text : $data; 134 | } 135 | } 136 | } -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "campaignmonitor/createsend-php", 3 | "type": "library", 4 | "description": "A php library which implements the complete functionality of the Campaign Monitor API.", 5 | "keywords": ["campaign", "monitor", "api"], 6 | "homepage": "http://campaignmonitor.github.io/createsend-php/", 7 | "license": "MIT", 8 | "authors": [ 9 | { 10 | "name": "Toby Brain", 11 | "email": "tobio85@gmail.com", 12 | "role": "Developer" 13 | } 14 | ], 15 | "require": { 16 | "php": ">=5.3.0" 17 | }, 18 | "require-dev": { 19 | "simpletest/simpletest": "1.2.0" 20 | }, 21 | "autoload": { 22 | "classmap": [ 23 | "csrest_administrators.php", 24 | "csrest_campaigns.php", 25 | "csrest_clients.php", 26 | "csrest_general.php", 27 | "csrest_events.php", 28 | "csrest_lists.php", 29 | "csrest_people.php", 30 | "csrest_segments.php", 31 | "csrest_subscribers.php", 32 | "csrest_templates.php", 33 | "csrest_transactional_classicemail.php", 34 | "csrest_transactional_smartemail.php", 35 | "csrest_transactional_timeline.php", 36 | "csrest_journeys.php", 37 | "csrest_journey_emails.php" 38 | ] 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "044b4a206e79d17a9a149f5869a31efa", 8 | "packages": [], 9 | "packages-dev": [ 10 | { 11 | "name": "simpletest/simpletest", 12 | "version": "v1.2.0", 13 | "source": { 14 | "type": "git", 15 | "url": "https://github.com/simpletest/simpletest.git", 16 | "reference": "4fb6006517a1428785a0ea704fbedcc675421ec4" 17 | }, 18 | "dist": { 19 | "type": "zip", 20 | "url": "https://api.github.com/repos/simpletest/simpletest/zipball/4fb6006517a1428785a0ea704fbedcc675421ec4", 21 | "reference": "4fb6006517a1428785a0ea704fbedcc675421ec4", 22 | "shasum": "" 23 | }, 24 | "require": { 25 | "php": "^7.1" 26 | }, 27 | "type": "library", 28 | "autoload": { 29 | "classmap": [ 30 | "." 31 | ] 32 | }, 33 | "notification-url": "https://packagist.org/downloads/", 34 | "license": [ 35 | "LGPL-2.0+" 36 | ], 37 | "authors": [ 38 | { 39 | "name": "Marcus Baker", 40 | "email": "marcus@lastcraft.com", 41 | "role": "Original project lead" 42 | }, 43 | { 44 | "name": "Jason Sweat", 45 | "role": "Original developer" 46 | }, 47 | { 48 | "name": "Travis Swicegood", 49 | "role": "Original developer" 50 | }, 51 | { 52 | "name": "Perrick Penet", 53 | "role": "Original developer" 54 | }, 55 | { 56 | "name": "Edward Z. Yang", 57 | "role": "Original developer" 58 | }, 59 | { 60 | "name": "Lachlan Donald", 61 | "email": "lachlan@ljd.cc" 62 | }, 63 | { 64 | "name": "Lars Vierbergen", 65 | "email": "vierbergenlars@gmail.com" 66 | }, 67 | { 68 | "name": "Jens A. Koch" 69 | } 70 | ], 71 | "description": "Unit testing, mock objects and web testing framework for PHP built around test cases.", 72 | "homepage": "http://simpletest.org/", 73 | "keywords": [ 74 | "SimpleTest", 75 | "code-coverage", 76 | "selenium", 77 | "testing", 78 | "unit-test" 79 | ], 80 | "support": { 81 | "issues": "https://github.com/simpletest/simpletest/issues", 82 | "source": "https://github.com/simpletest/simpletest/tree/master" 83 | }, 84 | "time": "2019-09-17T15:08:22+00:00" 85 | } 86 | ], 87 | "aliases": [], 88 | "minimum-stability": "stable", 89 | "stability-flags": [], 90 | "prefer-stable": false, 91 | "prefer-lowest": false, 92 | "platform": { 93 | "php": ">=5.3.0" 94 | }, 95 | "platform-dev": [], 96 | "plugin-api-version": "2.6.0" 97 | } 98 | -------------------------------------------------------------------------------- /csrest_administrators.php: -------------------------------------------------------------------------------- 1 | 'your access token', 28 | * 'refresh_token' => 'your refresh token') 29 | * 30 | * Or if using an API key: 31 | * array('api_key' => 'your api key') 32 | * @param $protocol string The protocol to use for requests (http|https) 33 | * @param $debug_level int The level of debugging required CS_REST_LOG_NONE | CS_REST_LOG_ERROR | CS_REST_LOG_WARNING | CS_REST_LOG_VERBOSE 34 | * @param $host string The host to send API requests to. There is no need to change this 35 | * @param $log CS_REST_Log The logger to use. Used for dependency injection 36 | * @param $serialiser The serialiser to use. Used for dependency injection 37 | * @param $transport The transport to use. Used for dependency injection 38 | * @access public 39 | */ 40 | function __construct ( 41 | $auth_details, 42 | $protocol = 'https', 43 | $debug_level = CS_REST_LOG_NONE, 44 | $host = 'api.createsend.com', 45 | $log = NULL, 46 | $serialiser = NULL, 47 | $transport = NULL) { 48 | 49 | parent::__construct($auth_details, $protocol, $debug_level, $host, $log, $serialiser, $transport); 50 | $this->_admins_base_route = $this->_base_route.'admins'; 51 | } 52 | 53 | /** 54 | * Adds a new administrator to the current account 55 | * @param array $admin The administrator details to use during creation. 56 | * This array should be of the form 57 | * array ( 58 | * 'EmailAddress' => The new administrator email address 59 | * 'Name' => The name of the new administrator 60 | * ) 61 | * @access public 62 | * @return CS_REST_Wrapper_Result A successful response will be empty 63 | */ 64 | function add($admin) { 65 | return $this->post_request($this->_admins_base_route.'.json', $admin); 66 | } 67 | 68 | /** 69 | * Updates details for an existing administrator associated with the current account 70 | * @param string $email The email address of the administrator to be updated 71 | * @param array $admin The updated administrator details to use for the update. 72 | * This array should be of the form 73 | * array ( 74 | * 'EmailAddress' => The new email address 75 | * 'Name' => The updated name of the administrator 76 | * ) 77 | * @access public 78 | * @return CS_REST_Wrapper_Result A successful response will be empty 79 | */ 80 | function update($email, $admin) { 81 | return $this->put_request($this->_admins_base_route.'.json?email='.urlencode($email), $admin); 82 | } 83 | 84 | /** 85 | * Gets the details for a specific administrator 86 | * @access public 87 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form 88 | * { 89 | * 'EmailAddress' => The email address of the administrator 90 | * 'Name' => The name of the administrator 91 | * 'Status' => The status of the administrator 92 | * ) 93 | * } 94 | */ 95 | function get($email) { 96 | return $this->get_request($this->_admins_base_route.'.json?email='.urlencode($email)); 97 | } 98 | 99 | 100 | /** 101 | * deletes the given administrator from the current account 102 | * @param string $email The email address of the administrator to delete 103 | * @access public 104 | * @return CS_REST_Wrapper_Result A successful response will be empty 105 | */ 106 | function delete($email) { 107 | return $this->delete_request($this->_admins_base_route.'.json?email='.urlencode($email)); 108 | } 109 | } 110 | } -------------------------------------------------------------------------------- /csrest_journeys.php: -------------------------------------------------------------------------------- 1 | 'your access token', 30 | * 'refresh_token' => 'your refresh token') 31 | * 32 | * Or if using an API key: 33 | * array('api_key' => 'your api key') 34 | * @param $protocol string The protocol to use for requests (http|https) 35 | * @param $debug_level int The level of debugging required CS_REST_LOG_NONE | CS_REST_LOG_ERROR | CS_REST_LOG_WARNING | CS_REST_LOG_VERBOSE 36 | * @param $host string The host to send API requests to. There is no need to change this 37 | * @param $log CS_REST_Log The logger to use. Used for dependency injection 38 | * @param $serialiser The serialiser to use. Used for dependency injection 39 | * @param $transport The transport to use. Used for dependency injection 40 | * @access public 41 | */ 42 | 43 | function __construct ( 44 | $journey_id, 45 | $auth_details, 46 | $protocol = 'https', 47 | $debug_level = CS_REST_LOG_NONE, 48 | $host = 'api.createsend.com', 49 | $log = NULL, 50 | $serialiser = NULL, 51 | $transport = NULL) { 52 | 53 | parent::__construct($auth_details, $protocol, $debug_level, $host, $log, $serialiser, $transport); 54 | $this->set_journey_id($journey_id); 55 | } 56 | 57 | 58 | /** 59 | * Change the email id used for calls after construction 60 | * @param $email_id 61 | * @access public 62 | */ 63 | function set_journey_id($journey_id) { 64 | $this->_journeys_base_route = $this->_base_route.'journeys/'.$journey_id; 65 | } 66 | 67 | /** 68 | * Gets the details of the current journey 69 | * @access public 70 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form 71 | * { 72 | * 'JourneyID' => The journey id 73 | * 'Name' => The name of the journey 74 | * 'TriggerType' => The method in which the journey was triggered 75 | * 'Status' => The status of the journey 76 | * 'Emails' => array( 77 | * { 78 | * 'EmailID' => The ID of the email attached to the journey 79 | * 'Name' => The name of the email attached to the journey 80 | * 'Bounced' => The number of recipients who bounced 81 | * 'Clicked' => The total number of recorded clicks 82 | * 'Opened' => The total number of recorded opens 83 | * 'Sent' => The total recipients of the journey email 84 | * 'UniqueOpened' => The number of recipients who opened 85 | * 'Unsubscribed' => The number of recipients who unsubscribed 86 | * } 87 | * ) 88 | * 89 | */ 90 | 91 | function get_journey_summary() { 92 | return $this->get_request(trim($this->_journeys_base_route, '/').'.json'); 93 | } 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /csrest_people.php: -------------------------------------------------------------------------------- 1 | 'your access token', 29 | * 'refresh_token' => 'your refresh token') 30 | * 31 | * Or if using an API key: 32 | * array('api_key' => 'your api key') 33 | * @param $protocol string The protocol to use for requests (http|https) 34 | * @param $debug_level int The level of debugging required CS_REST_LOG_NONE | CS_REST_LOG_ERROR | CS_REST_LOG_WARNING | CS_REST_LOG_VERBOSE 35 | * @param $host string The host to send API requests to. There is no need to change this 36 | * @param $log CS_REST_Log The logger to use. Used for dependency injection 37 | * @param $serialiser The serialiser to use. Used for dependency injection 38 | * @param $transport The transport to use. Used for dependency injection 39 | * @access public 40 | */ 41 | function __construct ( 42 | $client_id, 43 | $auth_details, 44 | $protocol = 'https', 45 | $debug_level = CS_REST_LOG_NONE, 46 | $host = 'api.createsend.com', 47 | $log = NULL, 48 | $serialiser = NULL, 49 | $transport = NULL) { 50 | 51 | parent::__construct($auth_details, $protocol, $debug_level, $host, $log, $serialiser, $transport); 52 | $this->set_client_id($client_id); 53 | 54 | } 55 | 56 | /** 57 | * Change the client id used for calls after construction 58 | * @param $client_id 59 | * @access public 60 | */ 61 | function set_client_id($client_id) { 62 | $this->_people_base_route = $this->_base_route.'clients/'.$client_id . '/people'; 63 | } 64 | 65 | /** 66 | * Adds a new person to the specified client 67 | * @param array $person The person details to use during creation. 68 | * This array should be of the form 69 | * array ( 70 | * 'EmailAddress' => The new person email address 71 | * 'Name' => The name of the new person 72 | * 'AccessLevel' => The access level of the new person. See http://www.campaignmonitor.com/api/clients/#setting_access_details for details 73 | * 'Password' => (optional) if not specified, an invitation will be sent to the person by email 74 | * ) 75 | * @access public 76 | * @return CS_REST_Wrapper_Result A successful response will be empty 77 | */ 78 | function add($person) { 79 | return $this->post_request($this->_people_base_route.'.json', $person); 80 | } 81 | 82 | /** 83 | * Updates details for an existing person associated with the specified client. 84 | * @param string $email The email address of the person to be updated 85 | * @param array $person The updated person details to use for the update. 86 | * This array should be of the form 87 | * array ( 88 | * 'EmailAddress' => The new email address 89 | * 'Name' => The name of the person 90 | * 'AccessLevel' => the access level of the person 91 | * 'Password' => (optional) if specified, changes the password to the specified value 92 | * ) 93 | * @access public 94 | * @return CS_REST_Wrapper_Result A successful response will be empty 95 | */ 96 | function update($email, $person) { 97 | return $this->put_request($this->_people_base_route.'.json?email='.urlencode($email), $person); 98 | } 99 | 100 | /** 101 | * Gets the details for a specific person 102 | * @access public 103 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form 104 | * { 105 | * 'EmailAddress' => The email address of the person 106 | * 'Name' => The name of the person 107 | * 'Status' => The status of the person 108 | * 'AccessLevel' => The access level of the person 109 | * ) 110 | * } 111 | */ 112 | function get($email) { 113 | return $this->get_request($this->_people_base_route.'.json?email='.urlencode($email)); 114 | } 115 | 116 | 117 | /** 118 | * deletes the given person from the current client 119 | * @param string $email The email address of the person to delete 120 | * @access public 121 | * @return CS_REST_Wrapper_Result A successful response will be empty 122 | */ 123 | function delete($email) { 124 | return $this->delete_request($this->_people_base_route.'.json?email='.urlencode($email)); 125 | } 126 | } 127 | } -------------------------------------------------------------------------------- /csrest_templates.php: -------------------------------------------------------------------------------- 1 | 'your access token', 28 | * 'refresh_token' => 'your refresh token') 29 | * 30 | * Or if using an API key: 31 | * array('api_key' => 'your api key') 32 | * @param $protocol string The protocol to use for requests (http|https) 33 | * @param $debug_level int The level of debugging required CS_REST_LOG_NONE | CS_REST_LOG_ERROR | CS_REST_LOG_WARNING | CS_REST_LOG_VERBOSE 34 | * @param $host string The host to send API requests to. There is no need to change this 35 | * @param $log CS_REST_Log The logger to use. Used for dependency injection 36 | * @param $serialiser The serialiser to use. Used for dependency injection 37 | * @param $transport The transport to use. Used for dependency injection 38 | * @access public 39 | */ 40 | function __construct ( 41 | $template_id, 42 | $auth_details, 43 | $protocol = 'https', 44 | $debug_level = CS_REST_LOG_NONE, 45 | $host = 'api.createsend.com', 46 | $log = NULL, 47 | $serialiser = NULL, 48 | $transport = NULL) { 49 | 50 | parent::__construct($auth_details, $protocol, $debug_level, $host, $log, $serialiser, $transport); 51 | $this->set_template_id($template_id); 52 | } 53 | 54 | /** 55 | * Change the template id used for calls after construction 56 | * @param $template_id 57 | * @access public 58 | */ 59 | function set_template_id($template_id) { 60 | $this->_templates_base_route = $this->_base_route.'templates/'.$template_id.'.json'; 61 | } 62 | 63 | /** 64 | * Creates a new template for the specified client based on the provided data 65 | * @param string $client_id The client to create the template for 66 | * @param array $template_details The details of the template 67 | * This should be an array of the form 68 | * array( 69 | * 'Name' => The name of the template 70 | * 'HtmlPageURL' => The url where the template html can be accessed 71 | * 'ZipFileURL' => The url where the template image zip can be accessed 72 | * ) 73 | * @access public 74 | * @return CS_REST_Wrapper_Result A successful response will be the ID of the newly created template 75 | */ 76 | function create($client_id, $template_details) { 77 | return $this->post_request($this->_base_route.'templates/'.$client_id.'.json', $template_details); 78 | } 79 | 80 | /** 81 | * Updates the current template with the provided code 82 | * @param array $template_details The details of the template 83 | * This should be an array of the form 84 | * array( 85 | * 'Name' => The name of the template 86 | * 'HtmlPageURL' => The url where the template html can be accessed 87 | * 'ZipFileURL' => The url where the template image zip can be accessed 88 | * ) 89 | * @access public 90 | * @return CS_REST_Wrapper_Result A successful response will be empty 91 | */ 92 | function update($template_details) { 93 | return $this->put_request($this->_templates_base_route, $template_details); 94 | } 95 | 96 | /** 97 | * Deletes the current template from the system 98 | * @access public 99 | * @return CS_REST_Wrapper_Result A successful response will be empty 100 | */ 101 | function delete() { 102 | return $this->delete_request($this->_templates_base_route); 103 | } 104 | 105 | /** 106 | * Gets the basic details of the current template 107 | * @access public 108 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form 109 | * { 110 | * 'TemplateID' => The id of the template 111 | * 'Name' => The name of the template 112 | * 'PreviewURL' => A url where the template can be previewed from 113 | * 'ScreenshotURL' => The url of the template screenshot if one was provided 114 | * } 115 | */ 116 | function get() { 117 | return $this->get_request($this->_templates_base_route); 118 | } 119 | } 120 | } -------------------------------------------------------------------------------- /csrest_transactional_classicemail.php: -------------------------------------------------------------------------------- 1 | 'your access token', 28 | * 'refresh_token' => 'your refresh token') 29 | * 30 | * Or if using an API key: 31 | * array('api_key' => 'your api key') 32 | * @param $protocol string The protocol to use for requests (http|https) 33 | * @param $debug_level int The level of debugging required CS_REST_LOG_NONE | CS_REST_LOG_ERROR | CS_REST_LOG_WARNING | CS_REST_LOG_VERBOSE 34 | * @param $host string The host to send API requests to. There is no need to change this 35 | * @param $log CS_REST_Log The logger to use. Used for dependency injection 36 | * @param $serialiser The serialiser to use. Used for dependency injection 37 | * @param $transport The transport to use. Used for dependency injection 38 | * @access public 39 | */ 40 | function __construct ( 41 | $auth_details, 42 | $client_id = NULL, 43 | $protocol = 'https', 44 | $debug_level = CS_REST_LOG_NONE, 45 | $host = 'api.createsend.com', 46 | $log = NULL, 47 | $serialiser = NULL, 48 | $transport = NULL) { 49 | parent::__construct($auth_details, $protocol, $debug_level, $host, $log, $serialiser, $transport); 50 | $this->set_client($client_id); 51 | } 52 | 53 | /** 54 | * Change the client id used for calls after construction 55 | * Only required if using OAuth or an Account level API Key 56 | * @param $client_id 57 | * @access public 58 | */ 59 | function set_client($client_id) { 60 | $this->_client_id_param = array("clientID" => $client_id); 61 | } 62 | 63 | /** 64 | * Sends a new classic transactional email 65 | * @param array $message The details of the template 66 | * This should be an array of the form 67 | * array( 68 | * 'From' => string required The From name/email in the form "first last " 69 | * 'ReplyTo' => string optional The Reply-To address 70 | * 'To' => array( 71 | * "First Last ", "another@example.com" 72 | * ) optional To recipients 73 | * 'CC' => array( 74 | * "First Last ", "another@example.com" 75 | * ) optional CC recipients 76 | * 'BCC' => array( 77 | * "First Last ", "another@example.com" 78 | * ) optional BCC recipients 79 | * 'Subject' => string required The subject of the email 80 | * 'Html' => string The HTML content of the message 81 | * 'Text' => string optional The text content of the message 82 | * 'Attachments' => array 83 | * "Name" => string required 84 | * "Type" => string required 85 | * "Content" => string required 86 | * ) optional 87 | * ) 88 | * @param string $group Optional. Name to group emails by for reporting 89 | * For example "Password reset", "Order confirmation" 90 | * @param array $options optional. Advanced options for sending this email (optional) 91 | * This should be an array, each property is optionals 92 | * array( 93 | * TrackOpens => whether to track opens, defaults to true 94 | * TrackClicks => whether to track clicks, defaults to true 95 | * InlineCSS => whether inline CSS, defaults to true 96 | * AddRecipientsToListID => ID of a list to add all recipeints to 97 | * ) 98 | * @access public 99 | * @return CS_REST_Wrapper_Result A successful response will be the include the details of the action, including a Message ID. 100 | * array( 101 | * array( 102 | * "MessageID" => string 103 | * "Recipient" => string 104 | * "Status" => string 105 | * ) 106 | * ) 107 | */ 108 | function send($message, $group = NULL, $consent_to_track, $add_to_list_ID = NULL, $options = array()) { 109 | $all_params = array( 110 | "Group" => $group, 111 | "AddRecipientsToListID" => $add_to_list_ID, 112 | "ConsentToTrack" => $consent_to_track 113 | ); 114 | $data = array_merge( 115 | $this->_client_id_param, $message, $all_params, $options 116 | ); 117 | return $this->post_request($this->_base_route.'transactional/classicemail/send', $data); 118 | } 119 | 120 | /** 121 | * Gets the list of Classic Groups 122 | * @access public 123 | * @return CS_REST_Wrapper_Result A successful response will be an array of the form 124 | * array( 125 | * array( 126 | * "Group" => string 127 | * "CreatedAt" => string 128 | * ) 129 | * ) 130 | */ 131 | function groups() { 132 | $data = array_merge($this->_client_id_param); 133 | return $this->get_request($this->_base_route . 'transactional/classicemail/groups', $data); 134 | } 135 | 136 | } 137 | } 138 | 139 | -------------------------------------------------------------------------------- /samples/authentication/auth_with_api_key.php: -------------------------------------------------------------------------------- 1 | 'your api key'); 6 | $wrap = new CS_REST_General($auth); 7 | 8 | $result = $wrap->get_clients(); 9 | 10 | 11 | echo "Result of /api/v3.1/clients\n
"; 12 | if($result->was_successful()) { 13 | echo "Got clients\n
";
14 |     var_dump($result->response);
15 | } else {
16 |     echo 'Failed with code '.$result->http_status_code."\n
";
17 |     var_dump($result->response);
18 | }
19 | echo '
'; -------------------------------------------------------------------------------- /samples/authentication/auth_with_oauth.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_General($auth); 9 | 10 | $result = $wrap->get_clients(); 11 | 12 | 13 | echo "Result of /api/v3.1/clients\n
"; 14 | if($result->was_successful()) { 15 | echo "Got clients\n
";
16 |     var_dump($result->response);
17 | } else {
18 |     echo 'Failed with code '.$result->http_status_code."\n
";
19 |     var_dump($result->response);
20 | }
21 | echo '
'; -------------------------------------------------------------------------------- /samples/authentication/exchange_token.php: -------------------------------------------------------------------------------- 1 | was_successful()) { 13 | $access_token = $result->response->access_token; 14 | $expires_in = $result->response->expires_in; 15 | $refresh_token = $result->response->refresh_token; 16 | # Save $access_token, $expires_in, and $refresh_token. 17 | echo "access token: ".$access_token."\n"; 18 | echo "expires in (seconds): ".$expires_in."\n"; 19 | echo "refresh token: ".$refresh_token."\n"; 20 | } else { 21 | echo 'An error occurred:\n'; 22 | echo $result->response->error.': '.$result->response->error_description."\n"; 23 | # Handle error... 24 | } 25 | -------------------------------------------------------------------------------- /samples/authentication/get_authorize_url.php: -------------------------------------------------------------------------------- 1 | "; 13 | -------------------------------------------------------------------------------- /samples/authentication/refresh_token.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token' 8 | ); 9 | $wrap = new CS_REST_General($auth); 10 | $result = $wrap->get_clients(); 11 | if (!$result->was_successful()) { 12 | # If you receive '121: Expired OAuth Token', refresh the access token 13 | if ($result->response->Code == 121) { 14 | list($new_access_token, $new_expires_in, $new_refresh_token) = 15 | $wrap->refresh_token(); 16 | # Save $new_access_token, $new_expires_in, and $new_refresh_token 17 | } 18 | # Make the call again 19 | $result = $wrap->get_clients(); 20 | } 21 | var_dump($result->response); 22 | -------------------------------------------------------------------------------- /samples/campaign/create.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Campaigns(NULL, $auth); 9 | 10 | $result = $wrap->create('Campaigns Client ID', array( 11 | 'Subject' => 'Campaign Subject', 12 | 'Name' => 'Campaign Name', 13 | 'FromName' => 'Campaign From Name', 14 | 'FromEmail' => 'Campaign From Email Address', 15 | 'ReplyTo' => 'Campaign Reply To Email Address', 16 | 'HtmlUrl' => 'Campaign HTML Import URL', 17 | # 'TextUrl' => 'Optional campaign text import URL', 18 | 'ListIDs' => array('First List', 'Second List'), 19 | 'SegmentIDs' => array('First Segment', 'Second Segment') 20 | )); 21 | 22 | echo "Result of POST /api/v3.1/campaigns/{clientID}\n
"; 23 | if($result->was_successful()) { 24 | echo "Created with ID\n
".$result->response; 25 | } else { 26 | echo 'Failed with code '.$result->http_status_code."\n
";
27 |     var_dump($result->response);
28 |     echo '
'; 29 | } -------------------------------------------------------------------------------- /samples/campaign/create_from_template.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Campaigns(NULL, $auth); 9 | 10 | $template_content = array( 11 | 'Singlelines' => array( 12 | array( 13 | 'Content' => 'This is a heading', 14 | 'Href' => 'http://example.com/' 15 | ) 16 | ), 17 | 'Multilines' => array( 18 | array( 19 | 'Content' => '

This is example

multiline content...

' 20 | ) 21 | ), 22 | 'Images' => array( 23 | array( 24 | 'Content' => 'http://example.com/image.png', 25 | 'Alt' => 'This is alt text for an image', 26 | 'Href' => 'http://example.com/' 27 | ) 28 | ), 29 | 'Repeaters' => array( 30 | array( 31 | 'Items' => array( 32 | array( 33 | 'Layout' => 'My layout', 34 | 'Singlelines' => array( 35 | array( 36 | 'Content' => 'This is a repeater heading', 37 | 'Href' => 'http://example.com/' 38 | ) 39 | ), 40 | 'Multilines' => array( 41 | array( 42 | 'Content' => '

This is example

multiline content...

' 43 | ) 44 | ), 45 | 'Images' => array( 46 | array( 47 | 'Content' => 'http://example.com/image.png', 48 | 'Alt' => 'This is alt text for a repeater image', 49 | 'Href' => 'http://example.com/' 50 | ) 51 | ) 52 | ) 53 | ) 54 | ) 55 | ) 56 | ); 57 | 58 | # $template_content as defined above would be used to fill the content of 59 | # a template with markup similar to the following: 60 | # 61 | # 62 | # My Template 63 | # 64 | #

Enter heading...

65 | #
Enter description...
66 | # 67 | # 68 | # 69 | #
70 | #

71 | #
72 | # 73 | #
74 | #
75 | #
76 | #

Unsubscribe

77 | # 78 | # 79 | 80 | $result = $wrap->create_from_template('Campaigns Client ID', array( 81 | 'Subject' => 'Campaign Subject', 82 | 'Name' => 'Campaign Name', 83 | 'FromName' => 'Campaign From Name', 84 | 'FromEmail' => 'Campaign From Email Address', 85 | 'ReplyTo' => 'Campaign Reply To Email Address', 86 | 'ListIDs' => array('First List', 'Second List'), 87 | 'SegmentIDs' => array('First Segment', 'Second Segment'), 88 | 'TemplateID' => 'Template ID', 89 | 'TemplateContent' => $template_content 90 | )); 91 | 92 | echo "Result of POST /api/v3.1/campaigns/{clientID}/fromtemplate\n
"; 93 | if($result->was_successful()) { 94 | echo "Created with ID\n
".$result->response; 95 | } else { 96 | echo 'Failed with code '.$result->http_status_code."\n
";
97 |     var_dump($result->response);
98 |     echo '
'; 99 | } -------------------------------------------------------------------------------- /samples/campaign/delete.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Campaigns('Campaign ID to Delete', $auth); 9 | $result = $wrap->delete(); 10 | 11 | echo "Result of DELETE /api/v3.1/campaigns/{id}\n
"; 12 | if($result->was_successful()) { 13 | echo "Deleted with code\n
".$result->http_status_code; 14 | } else { 15 | echo 'Failed with code '.$result->http_status_code."\n
";
16 |     var_dump($result->response);
17 |     echo '
'; 18 | } -------------------------------------------------------------------------------- /samples/campaign/get_bounces.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Campaigns('Campaign ID to get bounces for', $auth); 9 | $result = $wrap->get_bounces('Get bounces since', 1, 50, 'email', 'asc'); 10 | //$result = $wrap->get_bounces(page, page size, order field, order direction); 11 | 12 | echo "Result of GET /api/v3.1/campaigns/{id}/bounces\n
"; 13 | if($result->was_successful()) { 14 | echo "Got bounces\n
";
15 |     var_dump($result->response);
16 | } else {
17 |     echo 'Failed with code '.$result->http_status_code."\n
";
18 |     var_dump($result->response);
19 | }
20 | echo '
'; -------------------------------------------------------------------------------- /samples/campaign/get_clicks.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Campaigns('Campaign ID to get clicks for', $auth); 9 | $result = $wrap->get_clicks('Get clicks since', 1, 50, 'email', 'asc'); 10 | //$result = $wrap->get_clicks(date('Y-m-d', strtotime('-30 days')), page, page size, order field, order direction); 11 | 12 | echo "Result of GET /api/v3.1/campaigns/{id}/clicks\n
"; 13 | if($result->was_successful()) { 14 | echo "Got clicks\n
";
15 |     var_dump($result->response);
16 | } else {
17 |     echo 'Failed with code '.$result->http_status_code."\n
";
18 |     var_dump($result->response);
19 | }
20 | echo '
'; -------------------------------------------------------------------------------- /samples/campaign/get_email_client_usage.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Campaigns('Campaign ID to get the email client usage for', $auth); 9 | $result = $wrap->get_email_client_usage(); 10 | 11 | echo "Result of GET /api/v3.1/campaigns/{id}/emailclientusage\n
"; 12 | if($result->was_successful()) { 13 | echo "Got email client usage\n
";
14 |     var_dump($result->response);
15 | } else {
16 |     echo 'Failed with code '.$result->http_status_code."\n
";
17 |     var_dump($result->response);
18 | }
19 | echo '
'; -------------------------------------------------------------------------------- /samples/campaign/get_lists_and_segments.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Campaigns('Campaign ID to get lists for', $auth); 9 | $result = $wrap->get_lists_and_segments(); 10 | 11 | echo "Result of GET /api/v3.1/campaigns/{id}/listsandsegments\n
"; 12 | if($result->was_successful()) { 13 | echo "Got lists and segments\n
";
14 |     var_dump($result->response);
15 | } else {
16 |     echo 'Failed with code '.$result->http_status_code."\n
";
17 |     var_dump($result->response);
18 | }
19 | echo '
'; -------------------------------------------------------------------------------- /samples/campaign/get_opens.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Campaigns('Campaign ID to get opens for', $auth); 9 | $result = $wrap->get_opens('Get opens since', 1, 50, 'email', 'asc'); 10 | //$result = $wrap->get_opens(date('Y-m-d', strtotime('-30 days')), page, page size, order field, order direction); 11 | 12 | echo "Result of GET /api/v3.1/campaigns/{id}/opens\n
"; 13 | if($result->was_successful()) { 14 | echo "Got opens\n
";
15 |     var_dump($result->response);
16 | } else {
17 |     echo 'Failed with code '.$result->http_status_code."\n
";
18 |     var_dump($result->response);
19 | }
20 | echo '
'; -------------------------------------------------------------------------------- /samples/campaign/get_recipients.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Campaigns('Campaign ID to get recipients for', $auth); 9 | $result = $wrap->get_recipients(1, 50, 'email', 'asc'); 10 | //$result = $wrap->get_recipients(page number, page size, order by, order direction); 11 | 12 | echo "Result of GET /api/v3.1/campaigns/{id}/recipients\n
"; 13 | if($result->was_successful()) { 14 | echo "Got recipients\n
";
15 |     var_dump($result->response);
16 | } else {
17 |     echo 'Failed with code '.$result->http_status_code."\n
";
18 |     var_dump($result->response);
19 | }
20 | echo '
'; -------------------------------------------------------------------------------- /samples/campaign/get_spam.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Campaigns('Campaign ID to get spam complaints for', $auth); 9 | $result = $wrap->get_spam('Get spam complaints since', 1, 50, 'email', 'asc'); 10 | //$result = $wrap->get_spam(date('Y-m-d', strtotime('-30 days')), page, page size, order field, order direction); 11 | 12 | echo "Result of GET /api/v3.1/campaigns/{id}/spam\n
"; 13 | if($result->was_successful()) { 14 | echo "Got spam complaints\n
";
15 |     var_dump($result->response);
16 | } else {
17 |     echo 'Failed with code '.$result->http_status_code."\n
";
18 |     var_dump($result->response);
19 | }
20 | echo '
'; -------------------------------------------------------------------------------- /samples/campaign/get_summary.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Campaigns('Campaign ID to get the summary of', $auth); 9 | $result = $wrap->get_summary(); 10 | 11 | echo "Result of GET /api/v3.3/campaigns/{id}/summary\n
"; 12 | if($result->was_successful()) { 13 | echo "Got summary\n
";
14 |     var_dump($result->response);
15 | } else {
16 |     echo 'Failed with code '.$result->http_status_code."\n
";
17 |     var_dump($result->response);
18 | }
19 | echo '
'; -------------------------------------------------------------------------------- /samples/campaign/get_unsubscribes.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Campaigns('Campaign ID to get unsubscribes for', $auth); 9 | $result = $wrap->get_unsubscribes('Get unsubscribes since', 1, 50, 'email', 'asc'); 10 | //$result = $wrap->get_unsubscribes(date('Y-m-d', strtotime('-30 days')), page, page size, order field, order direction); 11 | 12 | echo "Result of GET /api/v3.1/campaigns/{id}/unsubscribes\n
"; 13 | if($result->was_successful()) { 14 | echo "Got unsubscribes\n
";
15 |     var_dump($result->response);
16 | } else {
17 |     echo 'Failed with code '.$result->http_status_code."\n
";
18 |     var_dump($result->response);
19 | }
20 | echo '
'; -------------------------------------------------------------------------------- /samples/campaign/send.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Campaigns('Campaign ID to Send', $auth); 9 | 10 | $result = $wrap->send(array( 11 | 'ConfirmationEmail' => 'Confirmation Email Address', 12 | 'SendDate' => 'Date to send (yyyy-mm-dd or immediately)' 13 | )); 14 | 15 | echo "Result of POST /api/v3.1/campaigns/{id}/send\n
"; 16 | if($result->was_successful()) { 17 | echo "Scheduled with code\n
".$result->http_status_code; 18 | } else { 19 | echo 'Failed with code '.$result->http_status_code."\n
";
20 |     var_dump($result->response);
21 |     echo '
'; 22 | } -------------------------------------------------------------------------------- /samples/campaign/send_preview.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Campaigns('Campaign ID to Test', $auth); 9 | $result = $wrap->send_preview(array( 10 | 'test1@test.com', 11 | 'test2@test.com' 12 | ), 'Fallback'); 13 | 14 | echo "Result of POST /api/v3.1/campaigns/{id}/sendpreview\n
"; 15 | if($result->was_successful()) { 16 | echo "Preview sent with code\n
".$result->http_status_code; 17 | } else { 18 | echo 'Failed with code '.$result->http_status_code."\n
";
19 |     var_dump($result->response);
20 |     echo '
'; 21 | } -------------------------------------------------------------------------------- /samples/campaign/unschedule.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Campaigns('Campaign ID to unschedule', $auth); 9 | 10 | $result = $wrap->unschedule(); 11 | 12 | echo "Result of POST /api/v3.1/campaigns/{id}/unschedule\n
"; 13 | if($result->was_successful()) { 14 | echo "Scheduled with code\n
".$result->http_status_code; 15 | } else { 16 | echo 'Failed with code '.$result->http_status_code."\n
";
17 |     var_dump($result->response);
18 |     echo '
'; 19 | } -------------------------------------------------------------------------------- /samples/client/create.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Clients(NULL, $auth); 9 | 10 | $result = $wrap->create(array( 11 | 'CompanyName' => 'Clients company name', 12 | 'Country' => 'Clients country', 13 | 'Timezone' => 'Clients timezone' 14 | )); 15 | 16 | echo "Result of POST /api/v3.1/clients\n
"; 17 | if($result->was_successful()) { 18 | echo "Created with ID\n
".$result->response; 19 | } else { 20 | echo 'Failed with code '.$result->http_status_code."\n
";
21 |     var_dump($result->response);
22 |     echo '
'; 23 | } -------------------------------------------------------------------------------- /samples/client/delete.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Clients('Client ID to Delete', $auth); 9 | 10 | $result = $wrap->delete(); 11 | 12 | echo "Result of DELETE /api/v3.1/clients/{id}\n
"; 13 | if($result->was_successful()) { 14 | echo 'Deleted'; 15 | } else { 16 | echo 'Failed with code '.$result->http_status_code."\n
";
17 |     var_dump($result->response);
18 |     echo '
'; 19 | } -------------------------------------------------------------------------------- /samples/client/get.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Clients('Your client ID', $auth); 9 | $result = $wrap->get(); 10 | 11 | echo "Result of GET /api/v3.1/clients/{id}\n
"; 12 | if($result->was_successful()) { 13 | echo "Got client
";
14 |     var_dump($result->response);
15 | } else {
16 |     echo 'Failed with code '.$result->http_status_code."\n
";
17 |     var_dump($result->response);
18 | }
19 | echo '
'; -------------------------------------------------------------------------------- /samples/client/get_campaigns.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Clients( 9 | 'ClientID to get Campaigns for', 10 | $auth); 11 | 12 | $result = $wrap->get_campaigns(); 13 | 14 | echo "Result of /api/v3.3/clients/{id}/campaigns\n
"; 15 | if($result->was_successful()) { 16 | echo "Got campaigns\n
";
17 |     var_dump($result->response);
18 | } else {
19 |     echo 'Failed with code '.$result->http_status_code."\n
";
20 |     var_dump($result->response);
21 | }
22 | echo '
'; -------------------------------------------------------------------------------- /samples/client/get_drafts.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Clients( 9 | 'ClientID to get drafts for', 10 | $auth); 11 | 12 | $result = $wrap->get_drafts(); 13 | 14 | echo "Result of /api/v3.3/clients/{id}/drafts\n
"; 15 | if($result->was_successful()) { 16 | echo "Got drafts\n
";
17 |     var_dump($result->response);
18 | } else {
19 |     echo 'Failed with code '.$result->http_status_code."\n
";
20 |     var_dump($result->response);
21 | }
22 | echo '
'; -------------------------------------------------------------------------------- /samples/client/get_journeys.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Clients( 9 | 'ClientID to get Journeys for', 10 | $auth); 11 | 12 | $result = $wrap->get_journeys(); 13 | 14 | echo "Result of /api/v3.2/clients/{id}/journeys\n
"; 15 | if($result->was_successful()) { 16 | echo "Got journeys\n
";
17 |     var_dump($result->response);
18 | } else {
19 |     echo 'Failed with code '.$result->http_status_code."\n
";
20 |     var_dump($result->response);
21 | }
22 | echo '
'; -------------------------------------------------------------------------------- /samples/client/get_lists.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Clients( 9 | 'ClientID to get Lists for', 10 | $auth); 11 | 12 | $result = $wrap->get_lists(); 13 | 14 | echo "Result of /api/v3.1/clients/{id}/lists\n
"; 15 | if($result->was_successful()) { 16 | echo "Got lists\n
";
17 |     var_dump($result->response);
18 | } else {
19 |     echo 'Failed with code '.$result->http_status_code."\n
";
20 |     var_dump($result->response);
21 | }
22 | echo '
'; -------------------------------------------------------------------------------- /samples/client/get_lists_for_email.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Clients( 9 | 'ClientID to get Lists for', 10 | $auth); 11 | 12 | $email_address = 'your_email_address@example.com'; 13 | 14 | $result = $wrap->get_lists_for_email($email_address); 15 | 16 | echo "Result of /api/v3.1/clients/{id}/listsforemail\n
"; 17 | if($result->was_successful()) { 18 | echo "Got lists to which email address ".$email_address." is subscribed\n
";
19 |     var_dump($result->response);
20 | } else {
21 |     echo 'Failed with code '.$result->http_status_code."\n
";
22 |     var_dump($result->response);
23 | }
24 | echo '
'; -------------------------------------------------------------------------------- /samples/client/get_scheduled.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Clients( 9 | 'ClientID to get scheduled campaigns for', 10 | $auth); 11 | 12 | $result = $wrap->get_scheduled(); 13 | 14 | echo "Result of /api/v3.3/clients/{id}/scheduled\n
"; 15 | if($result->was_successful()) { 16 | echo "Got scheduled campaigns\n
";
17 |     var_dump($result->response);
18 | } else {
19 |     echo 'Failed with code '.$result->http_status_code."\n
";
20 |     var_dump($result->response);
21 | }
22 | echo '
'; -------------------------------------------------------------------------------- /samples/client/get_segments.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Clients( 9 | 'ClientID to get segments for', 10 | $auth); 11 | 12 | $result = $wrap->get_segments(); 13 | 14 | echo "Result of /api/v3.1/clients/{id}/segments\n
"; 15 | if($result->was_successful()) { 16 | echo "Got segments\n
";
17 |     var_dump($result->response);
18 | } else {
19 |     echo 'Failed with code '.$result->http_status_code."\n
";
20 |     var_dump($result->response);
21 | }
22 | echo '
'; -------------------------------------------------------------------------------- /samples/client/get_suppressionlist.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Clients( 9 | 'ClientID to get the suppression list of', 10 | $auth); 11 | 12 | $result = $wrap->get_suppressionlist(1, 50, 'email', 'asc'); 13 | //$result = $wrap->get_suppressionlist(page number, page size, order by, order direction); 14 | 15 | echo "Result of /api/v3.1/clients/{id}/suppressionlist\n
"; 16 | if($result->was_successful()) { 17 | echo "Got suppression list\n
";
18 |     var_dump($result->response);
19 | } else {
20 |     echo 'Failed with code '.$result->http_status_code."\n
";
21 |     var_dump($result->response);
22 | }
23 | echo '
'; -------------------------------------------------------------------------------- /samples/client/get_tags.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Clients( 9 | 'ClientID to get Tags for', 10 | $auth); 11 | 12 | $result = $wrap->get_tags(); 13 | 14 | echo "Result of /api/v3.3/clients/{id}/tags\n
"; 15 | if($result->was_successful()) { 16 | echo "Got tags\n
";
17 |     var_dump($result->response);
18 | } else {
19 |     echo 'Failed with code '.$result->http_status_code."\n
";
20 |     var_dump($result->response);
21 | }
22 | echo '
'; -------------------------------------------------------------------------------- /samples/client/get_templates.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Clients( 9 | 'ClientID to get the templates of', 10 | $auth); 11 | 12 | $result = $wrap->get_templates(); 13 | 14 | echo "Result of /api/v3.1/clients/{id}/templates\n
"; 15 | if($result->was_successful()) { 16 | echo "Got templates\n
";
17 |     var_dump($result->response);
18 | } else {
19 |     echo 'Failed with code '.$result->http_status_code."\n
";
20 |     var_dump($result->response);
21 | }
22 | echo '
'; -------------------------------------------------------------------------------- /samples/client/set_basics.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Clients('Your client ID', $auth); 9 | 10 | $result = $wrap->set_basics(array( 11 | 'CompanyName' => 'Clients company name', 12 | 'Country' => 'Clients country', 13 | 'Timezone' => 'Clients timezone' 14 | )); 15 | 16 | echo "Result of PUT /api/v3.1/clients/{id}/setbasics\n
"; 17 | if($result->was_successful()) { 18 | echo "Updated with Code ".$result->http_status_code; 19 | } else { 20 | echo 'Failed with code '.$result->http_status_code."\n
";
21 |     var_dump($result->response);
22 |     echo '
'; 23 | } -------------------------------------------------------------------------------- /samples/client/set_monthly_billing.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Clients('Your client ID', $auth); 9 | 10 | $result = $wrap->set_monthly_billing(array( 11 | 'Currency' => 'USD', 12 | 'ClientPays' => true, 13 | 'MarkupPercentage' => 100/*, 14 | 'MonthlyScheme' => 'Basic' */ 15 | )); 16 | 17 | echo "Result of PUT /api/v3.1/clients/{id}/setmonthlybilling\n
"; 18 | if($result->was_successful()) { 19 | echo "Updated with Code ".$result->http_status_code; 20 | } else { 21 | echo 'Failed with code '.$result->http_status_code."\n
";
22 |     var_dump($result->response);
23 |     echo '
'; 24 | } -------------------------------------------------------------------------------- /samples/client/set_payg_billing.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Clients('Your client ID', $auth); 9 | 10 | /* 11 | * Specific markup values can be set via the 12 | * 13 | * MarkupOnDelivery 14 | * MarkupPerRecipient 15 | * MarkupOnDesignSpamTest 16 | * 17 | * fields 18 | */ 19 | $result = $wrap->set_payg_billing(array( 20 | 'Currency' => 'USD', 21 | 'ClientPays' => true, 22 | 'MarkupPercentage' => 100, 23 | 'CanPurchaseCredits' => false/*, 24 | 'MarkupOnDelivery' => 4, 25 | 'MarkupPerRecipient' => 3, 26 | 'MarkupOnDesignSpamTest' => 7 */ 27 | )); 28 | 29 | echo "Result of PUT /api/v3.1/clients/{id}/setpaygbilling\n
"; 30 | if($result->was_successful()) { 31 | echo "Updated with Code ".$result->http_status_code; 32 | } else { 33 | echo 'Failed with code '.$result->http_status_code."\n
";
34 |     var_dump($result->response);
35 |     echo '
'; 36 | } -------------------------------------------------------------------------------- /samples/client/suppress.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Clients('Your client ID', $auth); 9 | 10 | $emails = array( 11 | 'example@example.com', 12 | 'another@example.com' 13 | ); 14 | 15 | $result = $wrap->suppress($emails); 16 | 17 | echo "Result of PUT /api/v3.1/clients/{id}/suppress\n
"; 18 | if($result->was_successful()) { 19 | echo "Updated with Code ".$result->http_status_code; 20 | } else { 21 | echo 'Failed with code '.$result->http_status_code."\n
";
22 |     var_dump($result->response);
23 |     echo '
'; 24 | } -------------------------------------------------------------------------------- /samples/client/transfer_credits.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Clients('Client ID', $auth); 9 | 10 | $transfer_details = array( 11 | 'Credits' => 200, 12 | 'CanUseMyCreditsWhenTheyRunOut' => false 13 | ); 14 | 15 | $result = $wrap->transfer_credits($transfer_details); 16 | 17 | echo "Result of POST /api/v3.1/clients/{id}/credits\n
"; 18 | if($result->was_successful()) { 19 | echo "Transferred with response\n
";
20 |     var_dump($result->response);
21 | } else {
22 |     echo 'Failed with code '.$result->http_status_code."\n
";
23 |     var_dump($result->response);
24 |     echo '
'; 25 | } -------------------------------------------------------------------------------- /samples/client/unsuppress.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Clients('Your client ID', $auth); 9 | 10 | $result = $wrap->unsuppress('Email address to unsuppress'); 11 | 12 | echo "Result of PUT /api/v3.1/clients/{id}/unsuppress\n
"; 13 | if($result->was_successful()) { 14 | echo "Updated with Code ".$result->http_status_code; 15 | } else { 16 | echo 'Failed with code '.$result->http_status_code."\n
";
17 |     var_dump($result->response);
18 |     echo '
'; 19 | } -------------------------------------------------------------------------------- /samples/events/event_track.php: -------------------------------------------------------------------------------- 1 | "sample api key"); 5 | $client_id = "sample client id"; 6 | $api_event_type = "identify"; 7 | $wrap = new CS_REST_Events($auth, $client_id, $api_event_type); 8 | 9 | echo "\nSending a $api_event_type event...\n"; 10 | 11 | $contact = "joe@example.org"; 12 | $event_type = "checkout"; 13 | $event_data = array( 14 | "Page" => "/cart/checkout", 15 | "Items" => array( 16 | array( 17 | "Description" => "Rubber Widget", 18 | "Quantity" => 1, 19 | "Price" => 300, 20 | ), 21 | array( 22 | "Description" => "Paint 1L", 23 | "Quantity" => 10, 24 | "Price" => 1, 25 | ), 26 | ), 27 | "User" => "joe@example.org", 28 | "CardType" => "VISA", 29 | ); 30 | 31 | if (strcmp($wrap->getEventType(), "identify") === 0) { 32 | // `Identify` event 33 | $anon_id = "anonymousid-0"; 34 | $user_id = "userid-0"; 35 | $result = $wrap->track($contact, $event_type, $anon_id, $user_id, $event_data); 36 | } else { 37 | // `Non-identify` event (custom, shopify) 38 | $result = $wrap->track($contact, $event_type, NULL, NULL, $event_data); 39 | } 40 | echo "\nEvent Sent! Here's the response:\n"; 41 | var_dump($result); 42 | 43 | -------------------------------------------------------------------------------- /samples/external_session_url.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_General($auth); 9 | 10 | $result = $wrap->external_session_url(array( 11 | 'Email' => 'The email address of the Campaign Monitor user for whom the login session should be created', 12 | 'Chrome' => 'Which chrome to display - Must be either "all", "tabs", or "none"', 13 | 'Url' => 'The URL to display once logged in. e.g. "/subscribers/"', 14 | 'IntegratorID' => 'The Integrator ID. You need to contact Campaign Monitor support to get an Integrator ID.', 15 | 'ClientID' => 'The Client ID of the client which should be active once logged in to the Campaign Monitor account.' 16 | )); 17 | 18 | echo "Result of PUT /api/v3.1/externalsession\n
"; 19 | if($result->was_successful()) { 20 | echo "Succeeded with Code ".$result->http_status_code."\n
";
21 |     var_dump($result->response);
22 |     echo '
'; 23 | } else { 24 | echo 'Failed with code '.$result->http_status_code."\n
";
25 |     var_dump($result->response);
26 |     echo '
'; 27 | } -------------------------------------------------------------------------------- /samples/get_apikey.php: -------------------------------------------------------------------------------- 1 | get_apikey('Your username', 'Your password', 'account.test.createsend.com'); 8 | 9 | echo "Result of /api/v3.1/apikey\n
"; 10 | if($result->was_successful()) { 11 | echo "Got API Key\n
".$result->response->ApiKey; 12 | } else { 13 | echo 'Failed with code '.$result->http_status_code."\n
";
14 |     var_dump($result->response);
15 |     echo '
'; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /samples/get_billing_details.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_General($auth); 9 | 10 | 11 | $result = $wrap->get_billing_details(); 12 | 13 | echo "Result of /api/v3.1/billingdetails\n
"; 14 | if($result->was_successful()) { 15 | echo "Got billing details\n
";
16 |     var_dump($result->response);
17 | } else {
18 |     echo 'Failed with code '.$result->http_status_code."\n
";
19 |     var_dump($result->response);
20 | }
21 | echo '
'; -------------------------------------------------------------------------------- /samples/get_clients.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_General($auth); 9 | 10 | 11 | $result = $wrap->get_clients(); 12 | 13 | 14 | echo "Result of /api/v3.1/clients\n
"; 15 | if($result->was_successful()) { 16 | echo "Got clients\n
";
17 |     var_dump($result->response);
18 | } else {
19 |     echo 'Failed with code '.$result->http_status_code."\n
";
20 |     var_dump($result->response);
21 | }
22 | echo '
'; -------------------------------------------------------------------------------- /samples/get_countries.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_General($auth); 9 | 10 | 11 | $result = $wrap->get_countries(); 12 | 13 | echo "Result of /api/v3.1/countries\n
"; 14 | if($result->was_successful()) { 15 | echo "Got countries\n
";
16 |     var_dump($result->response);
17 | } else {
18 |     echo 'Failed with code '.$result->http_status_code."\n
";
19 |     var_dump($result->response);
20 | }
21 | echo '
'; -------------------------------------------------------------------------------- /samples/get_systemdate.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_General($auth); 9 | 10 | 11 | $result = $wrap->get_systemdate(); 12 | 13 | echo "Result of /api/v3.1/systemdate\n
"; 14 | if($result->was_successful()) { 15 | echo "Got system date\n
".$result->response->SystemDate; 16 | } else { 17 | echo 'Failed with code '.$result->http_status_code."\n
";
18 |     var_dump($result->response);
19 |     echo '
'; 20 | } -------------------------------------------------------------------------------- /samples/get_timezones.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_General($auth); 9 | 10 | 11 | $result = $wrap->get_timezones(); 12 | 13 | echo "Result of /api/v3.1/timezones\n
"; 14 | if($result->was_successful()) { 15 | echo "Got timezones\n
";
16 |     var_dump($result->response);
17 | } else {
18 |     echo 'Failed with code '.$result->http_status_code."\n
";
19 |     var_dump($result->response);
20 | }
21 | echo '
'; -------------------------------------------------------------------------------- /samples/journeys/get_journey_bounces.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_JourneyEmails('Email ID to get bounces for', $auth); 9 | 10 | //$result = $wrap->get_journey_bounces(date('Y-m-d', strtotime('-30 days')), page, page size, order direction); 11 | $result = $wrap->get_journey_bounces('Get bounces since', 1, 50, 'email', 'asc'); 12 | 13 | echo "Result of GET /api/v3.2/journeys/email/{id}/bounces\n
"; 14 | if($result->was_successful()) { 15 | echo "Got bounces\n
";
16 |     var_dump($result->response);
17 | } else {
18 |     echo 'Failed with code '.$result->http_status_code."\n
";
19 |     var_dump($result->response);
20 | }
21 | echo '
'; -------------------------------------------------------------------------------- /samples/journeys/get_journey_clicks.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_JourneyEmails('Email ID to get clicks for', $auth); 9 | 10 | //$result = $wrap->get_journey_clicks(date('Y-m-d', strtotime('-30 days')), page, page size, order direction); 11 | $result = $wrap->get_journey_clicks('Get clicks since', 1, 50, 'email', 'asc'); 12 | 13 | echo "Result of GET /api/v3.2/journeys/email/{id}/clicks\n
"; 14 | if($result->was_successful()) { 15 | echo "Got clicks\n
";
16 |     var_dump($result->response);
17 | } else {
18 |     echo 'Failed with code '.$result->http_status_code."\n
";
19 |     var_dump($result->response);
20 | }
21 | echo '
'; -------------------------------------------------------------------------------- /samples/journeys/get_journey_opens.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_JourneyEmails('Email ID to get opens for', $auth); 9 | 10 | //$result = $wrap->get_journey_opens(date('Y-m-d', strtotime('-30 days')), page, page size, order direction); 11 | $result = $wrap->get_journey_opens('Get opens since', 1, 50, 'email', 'asc'); 12 | 13 | echo "Result of GET /api/v3.2/journeys/email/{id}/opens\n
"; 14 | if($result->was_successful()) { 15 | echo "Got opens\n
";
16 |     var_dump($result->response);
17 | } else {
18 |     echo 'Failed with code '.$result->http_status_code."\n
";
19 |     var_dump($result->response);
20 | }
21 | echo '
'; -------------------------------------------------------------------------------- /samples/journeys/get_journey_recipients.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_JourneyEmails('Email ID to get recipients for', $auth); 9 | 10 | //$result = $wrap->get_journey_recipients(date('Y-m-d', strtotime('-30 days')), page, page size, order direction); 11 | $result = $wrap->get_journey_recipients('Get recipients since', 1, 50, 'email', 'asc'); 12 | 13 | echo "Result of GET /api/v3.2/journeys/email/{id}/recipients\n
"; 14 | if($result->was_successful()) { 15 | echo "Got recipients\n
";
16 |     var_dump($result->response);
17 | } else {
18 |     echo 'Failed with code '.$result->http_status_code."\n
";
19 |     var_dump($result->response);
20 | }
21 | echo '
'; -------------------------------------------------------------------------------- /samples/journeys/get_journey_summary.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Journeys('Journey ID to get the summary of', $auth); 9 | $result = $wrap->get_summary(); 10 | 11 | echo "Result of GET /api/v3.2/journeys/{id}\n
"; 12 | if($result->was_successful()) { 13 | echo "Got summary\n
";
14 |     var_dump($result->response);
15 | } else {
16 |     echo 'Failed with code '.$result->http_status_code."\n
";
17 |     var_dump($result->response);
18 | }
19 | echo '
'; -------------------------------------------------------------------------------- /samples/journeys/get_journey_unsubscribes.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_JourneyEmails('Email ID to get unsubscribes for', $auth); 9 | 10 | //$result = $wrap->get_journey_unsubscribes(date('Y-m-d', strtotime('-30 days')), page, page size, order direction); 11 | $result = $wrap->get_journey_unsubscribes('Get unsubscribes since', 1, 50, 'email', 'asc'); 12 | 13 | echo "Result of GET /api/v3.2/journeys/email/{id}/unsubscribes\n
"; 14 | if($result->was_successful()) { 15 | echo "Got unsubscribes\n
";
16 |     var_dump($result->response);
17 | } else {
18 |     echo 'Failed with code '.$result->http_status_code."\n
";
19 |     var_dump($result->response);
20 | }
21 | echo '
'; -------------------------------------------------------------------------------- /samples/list/activate_webhook.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Lists('List ID', $auth); 9 | 10 | $result = $wrap->activate_webhook('Webhook ID'); 11 | 12 | echo "Result of PUT /api/v3.1/lists/{ID}/webhooks/{WHID}/activate\n
"; 13 | if($result->was_successful()) { 14 | echo "Activated with code\n
".$result->http_status_code; 15 | } else { 16 | echo 'Failed with code '.$result->http_status_code."\n
";
17 |     var_dump($result->response);
18 |     echo '
'; 19 | } -------------------------------------------------------------------------------- /samples/list/create.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Lists(NULL, $auth); 9 | 10 | $result = $wrap->create('Lists Client ID', array( 11 | 'Title' => 'List Title', 12 | 'UnsubscribePage' => 'List unsubscribe page', 13 | 'ConfirmedOptIn' => false, 14 | 'ConfirmationSuccessPage' => 'List confirmation success page', 15 | 'UnsubscribeSetting' => CS_REST_LIST_UNSUBSCRIBE_SETTING_ALL_CLIENT_LISTS 16 | )); 17 | 18 | echo "Result of POST /api/v3.1/lists/{clientID}\n
"; 19 | if($result->was_successful()) { 20 | echo "Created with ID\n
".$result->response; 21 | } else { 22 | echo 'Failed with code '.$result->http_status_code."\n
";
23 |     var_dump($result->response);
24 |     echo '
'; 25 | } 26 | -------------------------------------------------------------------------------- /samples/list/create_custom_field.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Lists('List ID', $auth); 9 | 10 | /* 11 | * The DataType parameter must be one of 12 | * CS_REST_CUSTOM_FIELD_TYPE_TEXT 13 | * CS_REST_CUSTOM_FIELD_TYPE_NUMBER 14 | * CS_REST_CUSTOM_FIELD_TYPE_MULTI_SELECTONE 15 | * CS_REST_CUSTOM_FIELD_TYPE_MULTI_SELECTMANY 16 | * CS_REST_CUSTOM_FIELD_TYPE_DATE 17 | * CS_REST_CUSTOM_FIELD_TYPE_COUNTRY 18 | * CS_REST_CUSTOM_FIELD_TYPE_USSTATE 19 | * 20 | */ 21 | $result = $wrap->create_custom_field(array( 22 | 'FieldName' => 'Custom field name', 23 | 'DataType' => CS_REST_CUSTOM_FIELD_TYPE_MULTI_SELECTONE, 24 | 'Options' => array('First option', 'Second Option') 25 | )); 26 | 27 | echo "Result of POST /api/v3.1/lists/{ID}/customfields\n
"; 28 | if($result->was_successful()) { 29 | echo "Created with ID\n
".$result->response; 30 | } else { 31 | echo 'Failed with code '.$result->http_status_code."\n
";
32 |     var_dump($result->response);
33 |     echo '
'; 34 | } -------------------------------------------------------------------------------- /samples/list/create_webhook.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Lists('List ID', $auth); 9 | 10 | /* 11 | * The Events array must contain a combination of 12 | * CS_REST_LIST_WEBHOOK_SUBSCRIBE 13 | * CS_REST_LIST_WEBHOOK_DEACTIVATE 14 | * CS_REST_LIST_WEBHOOK_UPDATE 15 | * 16 | * The payload format must be one of 17 | * CS_REST_WEBHOOK_FORMAT_JSON or 18 | * CS_REST_WEBHOOK_FORMAT_XML 19 | */ 20 | $result = $wrap->create_webhook(array( 21 | 'Events' => array(CS_REST_LIST_WEBHOOK_SUBSCRIBE, CS_REST_LIST_WEBHOOK_DEACTIVATE), 22 | 'Url' => 'http://www.example.com/webhook_receiver.php', 23 | 'PayloadFormat' => CS_REST_WEBHOOK_FORMAT_JSON 24 | )); 25 | 26 | echo "Result of POST /api/v3.1/lists/{ID}/webhooks\n
"; 27 | if($result->was_successful()) { 28 | echo "Created with ID\n
".$result->response; 29 | } else { 30 | echo 'Failed with code '.$result->http_status_code."\n
";
31 |     var_dump($result->response);
32 |     echo '
'; 33 | } -------------------------------------------------------------------------------- /samples/list/deactivate_webhook.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Lists('List ID', $auth); 9 | 10 | $result = $wrap->deactivate_webhook('Webhook ID'); 11 | 12 | echo "Result of PUT /api/v3.1/lists/{ID}/webhooks/{WHID}/deactivate\n
"; 13 | if($result->was_successful()) { 14 | echo "Deactivated with code\n
".$result->http_status_code; 15 | } else { 16 | echo 'Failed with code '.$result->http_status_code."\n
";
17 |     var_dump($result->response);
18 |     echo '
'; 19 | } -------------------------------------------------------------------------------- /samples/list/delete.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Lists('List ID', $auth); 9 | 10 | $result = $wrap->delete(); 11 | 12 | echo "Result of DELETE /api/v3.1/lists/{ID}\n
"; 13 | if($result->was_successful()) { 14 | echo "Deleted with code\n
".$result->http_status_code; 15 | } else { 16 | echo 'Failed with code '.$result->http_status_code."\n
";
17 |     var_dump($result->response);
18 |     echo '
'; 19 | } -------------------------------------------------------------------------------- /samples/list/delete_custom_field.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Lists('List ID', $auth); 9 | 10 | $result = $wrap->delete_custom_field('Custom field key'); 11 | 12 | echo "Result of DELETE /api/v3.1/lists/{ID}/{Key}\n
"; 13 | if($result->was_successful()) { 14 | echo "Deleted with code\n
".$result->http_status_code; 15 | } else { 16 | echo 'Failed with code '.$result->http_status_code."\n
";
17 |     var_dump($result->response);
18 |     echo '
'; 19 | } -------------------------------------------------------------------------------- /samples/list/delete_webhook.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Lists('List ID', $auth); 9 | 10 | $result = $wrap->delete_webhook('Webhook ID'); 11 | 12 | echo "Result of DELETE /api/v3.1/lists/{ID}/webhooks/{WHID}\n
"; 13 | if($result->was_successful()) { 14 | echo "Deleted with code\n
".$result->http_status_code; 15 | } else { 16 | echo 'Failed with code '.$result->http_status_code."\n
";
17 |     var_dump($result->response);
18 |     echo '
'; 19 | } -------------------------------------------------------------------------------- /samples/list/get.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Lists('List ID', $auth); 9 | 10 | $result = $wrap->get(); 11 | 12 | echo "Result of GET /api/v3.1/lists/{ID}\n
"; 13 | if($result->was_successful()) { 14 | echo "Got list details\n
";
15 |     var_dump($result->response);
16 | } else {
17 |     echo 'Failed with code '.$result->http_status_code."\n
";
18 |     var_dump($result->response);
19 | }
20 | echo '
'; -------------------------------------------------------------------------------- /samples/list/get_active_subscribers.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Lists('List ID', $auth); 9 | 10 | //The 6th argument will return the tracking preference of the subscribers - 'ConsentToTrack' 11 | $result = $wrap->get_active_subscribers('Added since', 1, 50, 'email', 'asc', true); 12 | 13 | //$result = $wrap->get_active_subscribers(date('Y-m-d', strtotime('-30 days')), 14 | // page number, page size, order by, order direction); 15 | 16 | echo "Result of GET /api/v3.3/lists/{ID}/active\n
"; 17 | if($result->was_successful()) { 18 | echo "Got subscribers\n
";
19 |     var_dump($result->response);
20 | } else {
21 |     echo 'Failed with code '.$result->http_status_code."\n
";
22 |     var_dump($result->response);
23 | }
24 | echo '
'; -------------------------------------------------------------------------------- /samples/list/get_bounced_subscribers.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Lists('List ID', $auth); 9 | 10 | $result = $wrap->get_bounced_subscribers('Bounced Since', 1, 50, 'email', 'asc'); 11 | //$result = $wrap->get_bounced_subscribers(date('Y-m-d', strtotime('-30 days')), 12 | // page number, page size, order by, order direction); 13 | 14 | echo "Result of GET /api/v3.3/lists/{ID}/bounced\n
"; 15 | if($result->was_successful()) { 16 | echo "Got subscribers\n
";
17 |     var_dump($result->response);
18 | } else {
19 |     echo 'Failed with code '.$result->http_status_code."\n
";
20 |     var_dump($result->response);
21 | }
22 | echo '
'; -------------------------------------------------------------------------------- /samples/list/get_custom_fields.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Lists('List ID', $auth); 9 | 10 | $result = $wrap->get_custom_fields(); 11 | 12 | echo "Result of GET /api/v3.1/lists/{ID}/customfields\n
"; 13 | if($result->was_successful()) { 14 | echo "Got custom fields\n
";
15 |     var_dump($result->response);
16 | } else {
17 |     echo 'Failed with code '.$result->http_status_code."\n
";
18 |     var_dump($result->response);
19 | }
20 | echo '
'; -------------------------------------------------------------------------------- /samples/list/get_deleted_subscribers.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Lists('List ID', $auth); 9 | 10 | $result = $wrap->get_deleted_subscribers('Deleted Since', 1, 50, 'email', 'asc'); 11 | //$result = $wrap->get_bounced_subscribers(date('Y-m-d', strtotime('-30 days')), 12 | // page number, page size, order by, order direction); 13 | 14 | echo "Result of GET /api/v3.3/lists/{ID}/deleted\n
"; 15 | if($result->was_successful()) { 16 | echo "Got subscribers\n
";
17 |     var_dump($result->response);
18 | } else {
19 |     echo 'Failed with code '.$result->http_status_code."\n
";
20 |     var_dump($result->response);
21 | }
22 | echo '
'; -------------------------------------------------------------------------------- /samples/list/get_segments.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Lists('List ID', $auth); 9 | 10 | $result = $wrap->get_segments(); 11 | 12 | echo "Result of GET /api/v3.1/lists/{ID}/segments\n
"; 13 | if($result->was_successful()) { 14 | echo "Got custom fields\n
";
15 |     var_dump($result->response);
16 | } else {
17 |     echo 'Failed with code '.$result->http_status_code."\n
";
18 |     var_dump($result->response);
19 | }
20 | echo '
'; -------------------------------------------------------------------------------- /samples/list/get_stats.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Lists('List ID', $auth); 9 | 10 | $result = $wrap->get_stats(); 11 | 12 | echo "Result of GET /api/v3.1/lists/{ID}/stats\n
"; 13 | if($result->was_successful()) { 14 | echo "Got list stats\n
";
15 |     var_dump($result->response);
16 | } else {
17 |     echo 'Failed with code '.$result->http_status_code."\n
";
18 |     var_dump($result->response);
19 | }
20 | echo '
'; -------------------------------------------------------------------------------- /samples/list/get_unconfirmed_subscribers.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Lists('List ID', $auth); 9 | 10 | $result = $wrap->get_unconfirmed_subscribers('Added since', 1, 50, 'email', 'asc'); 11 | //$result = $wrap->get_active_subscribers(date('Y-m-d', strtotime('-30 days')), 12 | // page number, page size, order by, order direction); 13 | 14 | echo "Result of GET /api/v3.3/lists/{ID}/unconfirmed\n
"; 15 | if($result->was_successful()) { 16 | echo "Got subscribers\n
";
17 |     var_dump($result->response);
18 | } else {
19 |     echo 'Failed with code '.$result->http_status_code."\n
";
20 |     var_dump($result->response);
21 | }
22 | echo '
'; -------------------------------------------------------------------------------- /samples/list/get_unsubscribed_subscribers.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Lists('List ID', $auth); 9 | 10 | $result = $wrap->get_unsubscribed_subscribers('Unsubscribed Since', 1, 50, 'email', 'asc'); 11 | //$result = $wrap->get_bounced_subscribers(date('Y-m-d', strtotime('-30 days')), 12 | // page number, page size, order by, order direction); 13 | 14 | echo "Result of GET /api/v3.3/lists/{ID}/unsubscribed\n
"; 15 | if($result->was_successful()) { 16 | echo "Got subscribers\n
";
17 |     var_dump($result->response);
18 | } else {
19 |     echo 'Failed with code '.$result->http_status_code."\n
";
20 |     var_dump($result->response);
21 | }
22 | echo '
'; -------------------------------------------------------------------------------- /samples/list/get_webhooks.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Lists('List ID', $auth); 9 | 10 | $result = $wrap->get_webhooks(); 11 | 12 | echo "Result of GET /api/v3.1/lists/{ID}/webhooks\n
"; 13 | if($result->was_successful()) { 14 | echo "Got list webhooks\n
";
15 |     var_dump($result->response);
16 | } else {
17 |     echo 'Failed with code '.$result->http_status_code."\n
";
18 |     var_dump($result->response);
19 | }
20 | echo '
'; -------------------------------------------------------------------------------- /samples/list/list_webhook_receiver.php: -------------------------------------------------------------------------------- 1 | deserialise($raw_post); 19 | 20 | $parsed_log = fopen('parsed_log.txt', 'a') or die('Can\'t open parsed log'); 21 | 22 | fwrite($parsed_log, date('H:i:s').' Got hook data for list: '.$deserialised_data->ListID."\n"); 23 | 24 | // And now just do something with the data 25 | foreach ($deserialised_data->Events as $event) { 26 | fwrite($parsed_log, 'Got '.$event->Type.' event for: '.$event->EmailAddress."\n"); 27 | fwrite($parsed_log, var_export($event, true)); 28 | } 29 | 30 | fclose($parsed_log); 31 | ?> 32 | -------------------------------------------------------------------------------- /samples/list/test_webhook.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Lists('List ID', $auth); 9 | 10 | $result = $wrap->test_webhook('Webhook ID'); 11 | 12 | echo "Result of POST /api/v3.1/lists/{ID}/webhooks/{WHID}/test\n
"; 13 | if($result->was_successful()) { 14 | echo "Test was successful"; 15 | } else { 16 | echo 'Failed with code '.$result->http_status_code."\n
";
17 |     var_dump($result->response);
18 |     echo '
'; 19 | } -------------------------------------------------------------------------------- /samples/list/update.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Lists('List ID', $auth); 9 | 10 | $result = $wrap->update(array( 11 | 'Title' => 'List Title', 12 | 'UnsubscribePage' => 'List unsubscribe page', 13 | 'ConfirmedOptIn' => true, 14 | 'ConfirmationSuccessPage' => 'List confirmation success page', 15 | 'UnsubscribeSetting' => CS_REST_LIST_UNSUBSCRIBE_SETTING_ALL_CLIENT_LISTS, 16 | 'AddUnsubscribesToSuppList' => true, 17 | 'ScrubActiveWithSuppList' => true 18 | )); 19 | 20 | echo "Result of PUT /api/v3.1/lists/{ID}\n
"; 21 | if($result->was_successful()) { 22 | echo "Updated with code\n
".$result->http_status_code; 23 | } else { 24 | echo 'Failed with code '.$result->http_status_code."\n
";
25 |     var_dump($result->response);
26 |     echo '
'; 27 | } -------------------------------------------------------------------------------- /samples/list/update_custom_field.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Lists('List ID', $auth); 9 | 10 | $result = $wrap->update_custom_field( 11 | '[CustomFieldKey]', 12 | array( 13 | 'FieldName' => 'new field name', 14 | 'VisibleInPreferenceCenter' => true 15 | ) 16 | ); 17 | 18 | echo "Result of PUT /api/v3.1/lists/{ID}/customfields/{fieldkey}\n
"; 19 | if($result->was_successful()) { 20 | echo "Updated with code\n
".$result->http_status_code; 21 | } else { 22 | echo 'Failed with code '.$result->http_status_code."\n
";
23 |     var_dump($result->response);
24 |     echo '
'; 25 | } -------------------------------------------------------------------------------- /samples/list/update_field_options.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Lists('List ID', $auth); 9 | 10 | $result = $wrap->update_field_options('[CustomFieldKey]', 11 | array('Option 1', 'Option 2'), true); 12 | 13 | echo "Result of PUT /api/v3.1/lists/{ID}/customfields/{fieldkey}/options\n
"; 14 | if($result->was_successful()) { 15 | echo "Updated with code\n
".$result->http_status_code; 16 | } else { 17 | echo 'Failed with code '.$result->http_status_code."\n
";
18 |     var_dump($result->response);
19 |     echo '
'; 20 | } -------------------------------------------------------------------------------- /samples/segment/add_rule.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Segments('Segment ID', $auth); 9 | 10 | $result = $wrap->add_rulegroup(array( 11 | 'Rules' => array( 12 | array( 13 | 'RuleType' => 'EmailAddress', 14 | 'Clause' => 'CONTAINS example.com' 15 | ) 16 | ) 17 | )); 18 | 19 | echo "Result of PUT /api/v3.1/segments/{segmentID}/rules\n
"; 20 | if($result->was_successful()) { 21 | echo "Updated with code\n
".$result->http_status_code; 22 | } else { 23 | echo 'Failed with code '.$result->http_status_code."\n
";
24 |     var_dump($result->response);
25 |     echo '
'; 26 | } -------------------------------------------------------------------------------- /samples/segment/clear_rules.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Segments('Segment ID', $auth); 9 | 10 | $result = $wrap->clear_rules(); 11 | 12 | echo "Result of DELETE /api/v3.1/segments/{ID}/rules\n
"; 13 | if($result->was_successful()) { 14 | echo "Cleared with code\n
".$result->http_status_code; 15 | } else { 16 | echo 'Failed with code '.$result->http_status_code."\n
";
17 |     var_dump($result->response);
18 |     echo '
'; 19 | } -------------------------------------------------------------------------------- /samples/segment/create.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Segments(NULL, $auth); 9 | 10 | $result = $wrap->create('Segments List ID', array( 11 | 'Title' => 'Segment Title', 12 | 'RuleGroups' => array( 13 | array( 14 | 'Rules' => array( 15 | array( 16 | 'RuleType' => 'EmailAddress', 17 | 'Clause' => 'CONTAINS example.com' 18 | ) 19 | ) 20 | ), 21 | array( 22 | 'Rules' => array( 23 | array( 24 | 'RuleType' => '[customfield]', 25 | 'Clause' => 'PROVIDED' 26 | ), 27 | array( 28 | 'RuleType' => '[customfield]', 29 | 'Clause' => 'EQUALS 1' 30 | ) 31 | ) 32 | ) 33 | ) 34 | )); 35 | 36 | echo "Result of POST /api/v3.1/segments/{listID}\n
"; 37 | if($result->was_successful()) { 38 | echo "Created with ID\n
".$result->response; 39 | } else { 40 | echo 'Failed with code '.$result->http_status_code."\n
";
41 |     var_dump($result->response);
42 |     echo '
'; 43 | } -------------------------------------------------------------------------------- /samples/segment/delete.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Segments('Segment ID', $auth); 9 | 10 | 11 | $result = $wrap->delete(); 12 | 13 | echo "Result of DELETE /api/v3.1/segments/{ID}\n
"; 14 | if($result->was_successful()) { 15 | echo "Deleted with code\n
".$result->http_status_code; 16 | } else { 17 | echo 'Failed with code '.$result->http_status_code."\n
";
18 |     var_dump($result->response);
19 |     echo '
'; 20 | } -------------------------------------------------------------------------------- /samples/segment/get.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Segments('Segment ID', $auth); 9 | 10 | $result = $wrap->get(); 11 | 12 | echo "Result of GET /api/v3.1/segments/{ID}\n
"; 13 | if($result->was_successful()) { 14 | echo "Got segment details\n
";
15 |     var_dump($result->response);
16 | } else {
17 |     echo 'Failed with code '.$result->http_status_code."\n
";
18 |     var_dump($result->response);
19 | }
20 | echo '
'; -------------------------------------------------------------------------------- /samples/segment/get_subscribers.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Segments('Segment ID', $auth); 9 | 10 | //The 6th argument will return the tracking preference of the subscribers - 'ConsentToTrack' 11 | $result = $wrap->get_subscribers('Added since', 1, 50, 'email', 'asc', true); 12 | 13 | //$result = $wrap->get_subscribers(date('Y-m-d', strtotime('-30 days')), 14 | // page number, page size, order by, order description); 15 | 16 | echo "Result of GET /api/v3.3/segments/{segment id}/active\n
"; 17 | if($result->was_successful()) { 18 | echo "Got subscribers\n
";
19 |     var_dump($result->response);
20 | } else {
21 |     echo 'Failed with code '.$result->http_status_code."\n
";
22 |     var_dump($result->response);
23 | }
24 | echo '
'; -------------------------------------------------------------------------------- /samples/segment/update.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Segments('Segment ID', $auth); 9 | 10 | $result = $wrap->update(array( 11 | 'Title' => 'Segment Title', 12 | 'RuleGroups' => array( 13 | array( 14 | 'Rules' => array( 15 | array( 16 | 'RuleType' => 'EmailAddress', 17 | 'Clause' => 'CONTAINS example.com' 18 | ) 19 | ) 20 | ), 21 | array( 22 | 'Rules' => array( 23 | array( 24 | 'RuleType' => '[customfield]', 25 | 'Clause' => 'EQUALS 1' 26 | ) 27 | ) 28 | ) 29 | ) 30 | )); 31 | 32 | echo "Result of PUT /api/v3.1/segments/{segmentID}\n
"; 33 | if($result->was_successful()) { 34 | echo "Updated with code\n
".$result->http_status_code; 35 | } else { 36 | echo 'Failed with code '.$result->http_status_code."\n
";
37 |     var_dump($result->response);
38 |     echo '
'; 39 | } -------------------------------------------------------------------------------- /samples/subscriber/add.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Subscribers('Your list ID', $auth); 9 | $result = $wrap->add(array( 10 | 'EmailAddress' => 'Subscriber email', 11 | 'Name' => 'Subscriber name', 12 | 'CustomFields' => array( 13 | array( 14 | 'Key' => 'Field 1 Key', 15 | 'Value' => 'Field Value' 16 | ), 17 | array( 18 | 'Key' => 'Field 2 Key', 19 | 'Value' => 'Field Value' 20 | ), 21 | array( 22 | 'Key' => 'Multi Option Field 1', 23 | 'Value' => 'Option 1' 24 | ), 25 | array( 26 | 'Key' => 'Multi Option Field 1', 27 | 'Value' => 'Option 2' 28 | ) 29 | ), 30 | 'ConsentToTrack' => 'yes', 31 | 'Resubscribe' => true 32 | )); 33 | 34 | echo "Result of POST /api/v3.1/subscribers/{list id}.{format}\n
"; 35 | if($result->was_successful()) { 36 | echo "Subscribed with code ".$result->http_status_code; 37 | } else { 38 | echo 'Failed with code '.$result->http_status_code."\n
";
39 |     var_dump($result->response);
40 |     echo '
'; 41 | } -------------------------------------------------------------------------------- /samples/subscriber/delete.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Subscribers('Your list ID', $auth); 9 | $result = $wrap->delete('Email Address'); 10 | 11 | echo "Result of DELETE /api/v3.1/subscribers/{list id}.{format}?email={emailAddress}\n
"; 12 | if($result->was_successful()) { 13 | echo "Unsubscribed with code ".$result->http_status_code; 14 | } else { 15 | echo 'Failed with code '.$result->http_status_code."\n
";
16 |     var_dump($result->response);
17 |     echo '
'; 18 | } -------------------------------------------------------------------------------- /samples/subscriber/get.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Subscribers('Your list ID', $auth); 9 | 10 | //The 2nd argument will return the tracking preference of the subscriber - 'ConsentToTrack' 11 | $result = $wrap->get('Email address', true); 12 | 13 | echo "Result of GET /api/v3.3/subscribers/{list id}.{format}?email={email}\n
"; 14 | if($result->was_successful()) { 15 | echo "Got subscriber
";
16 |     var_dump($result->response);
17 | } else {
18 |     echo 'Failed with code '.$result->http_status_code."\n
";
19 |     var_dump($result->response);
20 | }
21 | echo '
'; -------------------------------------------------------------------------------- /samples/subscriber/get_history.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Subscribers('Your list ID', $auth); 9 | $result = $wrap->get_history('Email address'); 10 | 11 | echo "Result of GET /api/v3.1/subscribers/{list id}/history.{format}?email={email}\n
"; 12 | if($result->was_successful()) { 13 | echo "Got subscriber history
";
14 |     var_dump($result->response);
15 | } else {
16 |     echo 'Failed with code '.$result->http_status_code."\n
";
17 |     var_dump($result->response);
18 | }
19 | echo '
'; -------------------------------------------------------------------------------- /samples/subscriber/import.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Subscribers('Your list ID', $auth); 9 | 10 | $result = $wrap->import(array( 11 | array( 12 | 'EmailAddress' => 'Subscriber email', 13 | 'Name' => 'Subscriber name', 14 | 'CustomFields' => array( 15 | array( 16 | 'Key' => 'Field 1 Key', 17 | 'Value' => 'Field Value' 18 | ), 19 | array( 20 | 'Key' => 'Field 2 Key', 21 | 'Value' => 'Field Value' 22 | ), 23 | array( 24 | 'Key' => 'Multi Option Field 1', 25 | 'Value' => 'Option 1' 26 | ), 27 | array( 28 | 'Key' => 'Multi Option Field 1', 29 | 'Value' => 'Option 2' 30 | ) 31 | ), 32 | 'ConsentToTrack' => 'yes', 33 | ), 34 | array( 35 | 'EmailAddress' => '2nd Subscriber email', 36 | 'Name' => '2nd Subscriber name', 37 | 'CustomFields' => array( 38 | array( 39 | 'Key' => 'Field 1 Key', 40 | 'Value' => 'Field Value' 41 | ), 42 | array( 43 | 'Key' => 'Field 2 Key', 44 | 'Value' => 'Field Value' 45 | ), 46 | array( 47 | 'Key' => 'Multi Option Field 1', 48 | 'Value' => 'Option 1' 49 | ), 50 | array( 51 | 'Key' => 'Multi Option Field 1', 52 | 'Value' => 'Option 2' 53 | ) 54 | ), 55 | 'ConsentToTrack' => 'yes', 56 | ) 57 | ), false); 58 | 59 | echo "Result of POST /api/v3.1/subscribers/{list id}/import.{format}\n
"; 60 | if($result->was_successful()) { 61 | echo "Subscribed with results
";
62 |     var_dump($result->response);
63 | } else {
64 |     echo 'Failed with code '.$result->http_status_code."\n
";
65 |     var_dump($result->response);
66 |     echo '
'; 67 | 68 | if($result->response->ResultData->TotalExistingSubscribers > 0) { 69 | echo 'Updated '.$result->response->ResultData->TotalExistingSubscribers.' existing subscribers in the list'; 70 | } else if($result->response->ResultData->TotalNewSubscribers > 0) { 71 | echo 'Added '.$result->response->ResultData->TotalNewSubscribers.' to the list'; 72 | } else if(count($result->response->ResultData->DuplicateEmailsInSubmission) > 0) { 73 | echo $result->response->ResultData->DuplicateEmailsInSubmission.' were duplicated in the provided array.'; 74 | } 75 | 76 | echo 'The following emails failed to import correctly.
';
77 |     var_dump($result->response->ResultData->FailureDetails);
78 | }
79 | echo '
'; 80 | -------------------------------------------------------------------------------- /samples/subscriber/unsubscribe.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Subscribers('Your list ID', $auth); 9 | $result = $wrap->unsubscribe('Email Address'); 10 | 11 | echo "Result of GET /api/v3.1/subscribers/{list id}/unsubscribe.{format}\n
"; 12 | if($result->was_successful()) { 13 | echo "Unsubscribed with code ".$result->http_status_code; 14 | } else { 15 | echo 'Failed with code '.$result->http_status_code."\n
";
16 |     var_dump($result->response);
17 |     echo '
'; 18 | } -------------------------------------------------------------------------------- /samples/subscriber/update.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Subscribers('Your list ID', $auth); 9 | $result = $wrap->update('Old Email Address', array( 10 | 'EmailAddress' => 'New Email Address', 11 | 'Name' => 'Subscriber name', 12 | 'CustomFields' => array( 13 | array( 14 | 'Key' => 'Field Key', 15 | 'Value' => 'Field Value' 16 | ) 17 | ), 18 | 'ConsentToTrack' => 'unchanged', 19 | 'Resubscribe' => true 20 | )); 21 | 22 | echo "Result of PUT /api/v3.1/subscribers/{list id}.{format}?email={email}\n
"; 23 | if($result->was_successful()) { 24 | echo "Subscribed with code ".$result->http_status_code; 25 | } else { 26 | echo 'Failed with code '.$result->http_status_code."\n
";
27 |     var_dump($result->response);
28 |     echo '
'; 29 | } -------------------------------------------------------------------------------- /samples/template/create.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Templates(NULL, $auth); 9 | 10 | $result = $wrap->create('Templates Client ID', array( 11 | 'Name' => 'Template Name', 12 | 'HtmlPageURL' => 'Template HTML Url', 13 | 'ZipFileURL' => 'Template Images Zip URL' 14 | )); 15 | 16 | echo "Result of POST /api/v3.1/templates/{clientID}\n
"; 17 | if($result->was_successful()) { 18 | echo "Created with ID\n
".$result->response; 19 | } else { 20 | echo 'Failed with code '.$result->http_status_code."\n
";
21 |     var_dump($result->response);
22 |     echo '
'; 23 | } -------------------------------------------------------------------------------- /samples/template/delete.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Templates('Template ID', $auth); 9 | 10 | $result = $wrap->delete(); 11 | 12 | echo "Result of DELETE /api/v3.1/templates/{ID}\n
"; 13 | if($result->was_successful()) { 14 | echo "Deleted with code\n
".$result->http_status_code; 15 | } else { 16 | echo 'Failed with code '.$result->http_status_code."\n
";
17 |     var_dump($result->response);
18 |     echo '
'; 19 | } -------------------------------------------------------------------------------- /samples/template/get.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Templates('Template ID', $auth); 9 | 10 | $result = $wrap->get(); 11 | 12 | echo "Result of GET /api/v3.1/templates/{ID}\n
"; 13 | if($result->was_successful()) { 14 | echo "Got template details\n
";
15 |     var_dump($result->response);
16 | } else {
17 |     echo 'Failed with code '.$result->http_status_code."\n
";
18 |     var_dump($result->response);
19 | }
20 | echo '
'; -------------------------------------------------------------------------------- /samples/template/update.php: -------------------------------------------------------------------------------- 1 | 'your access token', 7 | 'refresh_token' => 'your refresh token'); 8 | $wrap = new CS_REST_Templates('Template ID', $auth); 9 | 10 | $result = $wrap->update(array( 11 | 'Name' => 'Template Name', 12 | 'HtmlPageURL' => 'Template HTML Url', 13 | 'ZipFileURL' => 'Template Images Zip URL' 14 | )); 15 | 16 | echo "Result of PUT /api/v3.1/templates/{ID}\n
"; 17 | if($result->was_successful()) { 18 | echo "Updated with code\n
".$result->http_status_code; 19 | } else { 20 | echo 'Failed with code '.$result->http_status_code."\n
";
21 |     var_dump($result->response);
22 |     echo '
'; 23 | } -------------------------------------------------------------------------------- /samples/transactional/classic_groups.php: -------------------------------------------------------------------------------- 1 | "Your API Key"); 6 | 7 | $wrap = new CS_REST_Transactional_ClassicEmail($auth, $client_id); 8 | 9 | echo "Get the list of classic groups...\n"; 10 | $result = $wrap->groups(); 11 | var_dump($result->response); 12 | 13 | -------------------------------------------------------------------------------- /samples/transactional/classic_send.php: -------------------------------------------------------------------------------- 1 | "Your API Key"); 6 | $wrap = new CS_REST_Transactional_ClassicEmail($auth, $client_id); 7 | 8 | echo "\nSending a simple message...\n"; 9 | 10 | $simple_message = array( 11 | "From" => "support@example.com", 12 | "Subject" => "Test from createsend-php", 13 | "To" => "Joe Bloggs ", 14 | "HTML" => "This is the HTML message body with a link." 15 | ); 16 | $group_name = 'PHP test group'; # optional but great for reporting, should not be unique per message 17 | $consent_to_track = 'yes'; # Valid: 'yes', 'no', 'unchanged' 18 | 19 | $result = $wrap->send($simple_message, $group_name,$consent_to_track); 20 | echo "\nSent! Here's the response:\n"; 21 | var_dump($result->response); 22 | 23 | echo "\nSending a message with all the options...\n"; 24 | 25 | $complex_message = array( 26 | "From" => "ed@example.com", 27 | "ReplyTo" => "support@example.com", 28 | "Subject" => "Test from createsend-php", 29 | "To" => array( 30 | "Sam Jones ", 31 | "jane@example.org" 32 | ), 33 | "CC" => array( 34 | "Mike ", 35 | "Sally Perlis " 36 | ), 37 | "BCC" => array( 38 | "tim@example.com", 39 | "allison@example.com", 40 | ), 41 | "HTML" => "This is the HTML message body with a link.", 42 | "Text" => "Instead of using the auto-generated text from the HTML, you can supply your own.", 43 | "Attachments" => array( 44 | array( 45 | "Name" => "filename.gif", 46 | "Type" => "image/gif", 47 | "Content" => "R0lGODlhIAAgAKIAAP8AAJmZADNmAMzMAP//AAAAAP///wAAACH/C1hNUCBEYXRhWE1QPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMwMTQgNzkuMTU2Nzk3LCAyMDE0LzA4LzIwLTA5OjUzOjAyICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ0MgMjAxNCAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDowNzZGOUNGOUVDRDIxMUU0ODM2RjhGMjNCMTcxN0I2RiIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDowNzZGOUNGQUVDRDIxMUU0ODM2RjhGMjNCMTcxN0I2RiI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjA3NkY5Q0Y3RUNEMjExRTQ4MzZGOEYyM0IxNzE3QjZGIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjA3NkY5Q0Y4RUNEMjExRTQ4MzZGOEYyM0IxNzE3QjZGIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+Af/+/fz7+vn49/b19PPy8fDv7u3s6+rp6Ofm5eTj4uHg397d3Nva2djX1tXU09LR0M/OzczLysnIx8bFxMPCwcC/vr28u7q5uLe2tbSzsrGwr66trKuqqainpqWko6KhoJ+enZybmpmYl5aVlJOSkZCPjo2Mi4qJiIeGhYSDgoGAf359fHt6eXh3dnV0c3JxcG9ubWxramloZ2ZlZGNiYWBfXl1cW1pZWFdWVVRTUlFQT05NTEtKSUhHRkVEQ0JBQD8+PTw7Ojk4NzY1NDMyMTAvLi0sKyopKCcmJSQjIiEgHx4dHBsaGRgXFhUUExIREA8ODQwLCgkIBwYFBAMCAQAAIfkEAAAAAAAsAAAAACAAIAAAA5loutz+MKpSpIWU3r1KCBW3eYQmWgWhmiemEgPbNqk6xDOd1XGYV77UzTfbTWC4nAHYQRKLu1VSuXxlpsodAFDAZrfcIbXDFXqhNacoQ3vZpuxHSJZ2zufyTqcunugdd00vQ0F4chQCAgYCaTcxiYuMMhGJFG89kYpFl5MzkoRPnpJskFSaDqctRoBxHEQsdGs0f7Qjq3utDwkAOw==" 48 | ) 49 | ) 50 | ); 51 | $group_name = "PHP test group"; # optional, great for reporting, should not be unique message 52 | $add_recipients_to_subscriber_list_ID = "6d0366fcee146ab9bdaf3247446bbfdd"; # optional, make sure you have permission 53 | $consent_to_track = 'yes'; # Valid: 'yes', 'no', 'unchanged' 54 | 55 | $options = array( 56 | "TrackOpens" => true, 57 | "TrackClicks" => true, 58 | "InlineCSS" => true, 59 | ); # all are true by default, but you can override 60 | $result = $wrap->send($complex_message, $group_name, $consent_to_track, $add_recipients_to_subscriber_list_ID, $options); 61 | echo "\nSent! Here's the response:\n"; 62 | var_dump($result->response); 63 | 64 | -------------------------------------------------------------------------------- /samples/transactional/smart_details.php: -------------------------------------------------------------------------------- 1 | "Your API Key"); 5 | 6 | $smart_email_id = "Smart Email ID goes here"; #grab it from the URL 7 | $wrap = new CS_REST_Transactional_SmartEmail($smart_email_id, $auth); 8 | 9 | echo "\nGetting the details of the smart email...\n"; 10 | $result = $wrap->get_details($smart_email_id); 11 | var_dump($result->response); 12 | 13 | -------------------------------------------------------------------------------- /samples/transactional/smart_list.php: -------------------------------------------------------------------------------- 1 | "Your API Key"); 6 | $wrap = new CS_REST_Transactional_SmartEmail(NULL, $auth, $client_id); 7 | 8 | echo "\nGetting the list of smart emails...\n"; 9 | 10 | $result = $wrap->get_list(); 11 | echo "Found " . count($result->response) . " smart emails, here's the first in the list:\n"; 12 | var_dump($result->response); 13 | 14 | 15 | echo "\nGetting the list smart emails, filtered by status...\n"; 16 | 17 | $total = $wrap->get_list(array("status" => 'all'))->response; 18 | $active = $wrap->get_list(array("status" => 'active'))->response; 19 | $draft = $wrap->get_list(array("status" => 'draft'))->response; 20 | echo "Found " . count($active) . " active and " . count($draft) . " draft smart emails, for a total of " . count($total) . " smart emails.\n"; 21 | 22 | -------------------------------------------------------------------------------- /samples/transactional/smart_send.php: -------------------------------------------------------------------------------- 1 | "Your API Key"); 5 | $smart_email_id = "Smart Email ID goes here"; #grab it from the URL 6 | $wrap = new CS_REST_Transactional_SmartEmail($smart_email_id, $auth); 7 | 8 | echo "\nSending a simple smart email...\n"; 9 | 10 | $simple_message = array( 11 | "To" => "Jane Bloggs ", 12 | "Data" => array( 13 | "username" => "janebloggs" 14 | ), 15 | ); 16 | $consent_to_track = 'yes'; # Valid: 'yes', 'no', 'unchanged' 17 | $result = $wrap->send($simple_message, $consent_to_track); 18 | echo "\nSent! Here's the response:\n"; 19 | var_dump($result->response); 20 | 21 | 22 | echo "\nSending a message with all the options...\n"; 23 | 24 | $complex_message = array( 25 | "To" => array( 26 | "Sam Jones ", 27 | "Phil Oye ", 28 | "jane@example.org" 29 | ), 30 | "CC" => array( 31 | "Mike ", 32 | "Sally Perlis " 33 | ), 34 | "BCC" => array( 35 | "tim@example.com", 36 | "allison@example.com" 37 | ), 38 | "Data" => array( 39 | "username" => "janebloggs" 40 | ), 41 | "Attachments" => array( 42 | array( 43 | "Name" => 'filename.gif', 44 | "Type" => 'image/gif', 45 | "Content" => 'R0lGODlhIAAgAKIAAP8AAJmZADNmAMzMAP//AAAAAP///wAAACH/C1hNUCBEYXRhWE1QPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMwMTQgNzkuMTU2Nzk3LCAyMDE0LzA4LzIwLTA5OjUzOjAyICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ0MgMjAxNCAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDowNzZGOUNGOUVDRDIxMUU0ODM2RjhGMjNCMTcxN0I2RiIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDowNzZGOUNGQUVDRDIxMUU0ODM2RjhGMjNCMTcxN0I2RiI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjA3NkY5Q0Y3RUNEMjExRTQ4MzZGOEYyM0IxNzE3QjZGIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjA3NkY5Q0Y4RUNEMjExRTQ4MzZGOEYyM0IxNzE3QjZGIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+Af/+/fz7+vn49/b19PPy8fDv7u3s6+rp6Ofm5eTj4uHg397d3Nva2djX1tXU09LR0M/OzczLysnIx8bFxMPCwcC/vr28u7q5uLe2tbSzsrGwr66trKuqqainpqWko6KhoJ+enZybmpmYl5aVlJOSkZCPjo2Mi4qJiIeGhYSDgoGAf359fHt6eXh3dnV0c3JxcG9ubWxramloZ2ZlZGNiYWBfXl1cW1pZWFdWVVRTUlFQT05NTEtKSUhHRkVEQ0JBQD8+PTw7Ojk4NzY1NDMyMTAvLi0sKyopKCcmJSQjIiEgHx4dHBsaGRgXFhUUExIREA8ODQwLCgkIBwYFBAMCAQAAIfkEAAAAAAAsAAAAACAAIAAAA5loutz+MKpSpIWU3r1KCBW3eYQmWgWhmiemEgPbNqk6xDOd1XGYV77UzTfbTWC4nAHYQRKLu1VSuXxlpsodAFDAZrfcIbXDFXqhNacoQ3vZpuxHSJZ2zufyTqcunugdd00vQ0F4chQCAgYCaTcxiYuMMhGJFG89kYpFl5MzkoRPnpJskFSaDqctRoBxHEQsdGs0f7Qjq3utDwkAOw==' 46 | ) 47 | ) 48 | ); 49 | 50 | $add_recipients_to_subscriber_list = true; 51 | $consent_to_track = 'yes'; # Valid: 'yes', 'no', 'unchanged' 52 | 53 | $result = $wrap->send($complex_message, $consent_to_track, $add_recipients_to_subscriber_list); 54 | echo "\nSent! Here's the response:\n"; 55 | var_dump($result->response); 56 | 57 | -------------------------------------------------------------------------------- /samples/transactional/timeline.php: -------------------------------------------------------------------------------- 1 | "Your API Key"); 6 | $wrap = new CS_REST_Transactional_Timeline($auth, $client_id); 7 | 8 | 9 | echo "\nGetting the statistics with the default parameters...\n"; 10 | $result = $wrap->statistics(); 11 | var_dump($result->response); 12 | 13 | 14 | echo "\nGetting the statistics, filtered to a classic group...\n"; 15 | $result = $wrap->statistics(array( 16 | "from" => "2015-01-01", 17 | "to" => "2015-06-30", 18 | "timezone" => "utc", 19 | "group" => "PHP Test Group" 20 | )); 21 | var_dump($result->response); 22 | 23 | 24 | echo "\nGetting the statistics, filtered to a smart email...\n"; 25 | $smart_email_id = "94b2a1a5-6754-416b-a87f-1edb81c460a2"; #grab it from the URL 26 | $result = $wrap->statistics(array( 27 | "from" => "2015-01-01", 28 | "to" => "2015-06-30", 29 | "timezone" => "client", 30 | "smartEmailID" => $smart_email_id 31 | )); 32 | var_dump($result->response); 33 | 34 | 35 | echo "\nGetting the most recent sent messages...\n"; 36 | $result = $wrap->messages(); 37 | $last_message_id = $result->response[0]->MessageID; 38 | echo "\nHere's the first:\n"; 39 | var_dump($result->response[0]); 40 | 41 | 42 | echo "\nGetting the most recent messages for a smart email, with all the options...\n"; 43 | $result = $wrap->messages(array( 44 | "status" => 'all', 45 | "count" => 200, 46 | "sentBeforeID" => NULL, # message ID 47 | "sentAfterID" => NULL, # message ID 48 | "smartEmailID" => '94b2a1a5-6754-416b-a87f-1edb81c460a2', 49 | )); 50 | $last_message_id = $result->response[0]->MessageID; 51 | echo "\nHere's the first:\n"; 52 | var_dump($result->response[0]); 53 | 54 | 55 | echo "\nGetting the most recent messages for a classic email, with all the options...\n"; 56 | $result = $wrap->messages(array( 57 | "status" => 'all', 58 | "count" => 200, 59 | "sentBeforeID" => NULL, # message ID 60 | "sentAfterID" => NULL, # message ID 61 | "group" => 'PHP test group', 62 | )); 63 | $last_message_id = $result->response[0]->MessageID; 64 | echo "\nHere's the first:\n"; 65 | var_dump($result->response[0]); 66 | 67 | 68 | echo "\nGetting the details of the most recent message...\n"; 69 | $result = $wrap->details($last_message_id); 70 | var_dump($result->response); 71 | 72 | 73 | echo "\nGetting the message details with details of opens and clicks...\n"; 74 | $result = $wrap->details($last_message_id, true); 75 | var_dump($result->response); 76 | 77 | 78 | echo "\nResending message...\n"; 79 | $result = $wrap->resend($last_message_id); 80 | var_dump($result->response); 81 | 82 | -------------------------------------------------------------------------------- /tests/all_tests.php: -------------------------------------------------------------------------------- 1 | addFile('class_tests/transport_test.php'); 12 | $this->addFile('class_tests/response_tests.php'); 13 | $this->addFile('csrest_test.php'); 14 | $this->addFile('csrest_clients_test.php'); 15 | $this->addFile('csrest_campaigns_test.php'); 16 | $this->addFile('csrest_lists_test.php'); 17 | $this->addFile('csrest_subscribers_test.php'); 18 | $this->addFile('csrest_template_test.php'); 19 | $this->addFile('csrest_segments_test.php'); 20 | $this->addFile('csrest_people_test.php'); 21 | $this->addFile('csrest_administrators_test.php'); 22 | $this->addFile('csrest_events_test.php'); 23 | $this->addFile('csrest_journeys_test.php'); 24 | $this->addFile('csrest_journey_emails_test.php'); 25 | } 26 | } -------------------------------------------------------------------------------- /tests/csrest_administrators_test.php: -------------------------------------------------------------------------------- 1 | 'not a real api key'); 12 | } 13 | 14 | class CS_REST_OAuthTestAdministrator extends CS_REST_TestAdministrator { 15 | var $auth = array( 16 | 'access_token' => '7y872y3872i3eh', 17 | 'refresh_token' => 'kjw8qjd9ow8jo'); 18 | } 19 | 20 | abstract class CS_REST_TestAdministrator extends CS_REST_TestBase { 21 | var $admins_base_route; 22 | 23 | function set_up_inner() { 24 | $this->admins_base_route = $this->base_route.'admins'; 25 | $this->wrapper = new CS_REST_Administrators($this->auth, $this->protocol, $this->log_level, 26 | $this->api_host, $this->mock_log, $this->mock_serialiser, $this->mock_transport); 27 | } 28 | 29 | function testadd() { 30 | $raw_result = ''; 31 | 32 | $call_options = $this->get_call_options($this->admins_base_route.'.json', 'POST'); 33 | 34 | $admin = array ( 35 | 'EmailAddress' => 'test@test.com', 36 | 'Name' => 'Widget Man!' 37 | ); 38 | 39 | $this->general_test_with_argument('add', $admin, $call_options, 40 | $raw_result, $raw_result, 'administrator was serialised to this'); 41 | } 42 | 43 | function testupdate() { 44 | $raw_result = ''; 45 | $email = 'test@test.com'; 46 | $serialised_admin = 'subscriber data'; 47 | 48 | $call_options = $this->get_call_options( 49 | $this->admins_base_route.'.json?email='.urlencode($email), 'PUT'); 50 | 51 | $admin = array ( 52 | 'EmailAddress' => 'test2@test.com', 53 | 'Name' => 'Widget Man!', 54 | ); 55 | 56 | $transport_result = array ( 57 | 'code' => 200, 58 | 'response' => $raw_result 59 | ); 60 | 61 | $expected_result = new CS_REST_Wrapper_Result($raw_result, 200); 62 | $call_options['data'] = $serialised_admin; 63 | 64 | $this->setup_transport_and_serialisation($transport_result, $call_options, 65 | $raw_result, $raw_result, $serialised_admin, 66 | $admin, 200); 67 | 68 | $result = $this->wrapper->update($email, $admin); 69 | 70 | $this->assertIdentical($expected_result, $result); 71 | } 72 | 73 | function testget() { 74 | $raw_result = 'administrator details'; 75 | $deserialised = array(1,2,34,5); 76 | $response_code = 200; 77 | $email = 'test@test.com'; 78 | 79 | $call_options = $this->get_call_options( 80 | $this->admins_base_route.'.json?email='.urlencode($email), 'GET'); 81 | 82 | $transport_result = array ( 83 | 'code' => $response_code, 84 | 'response' => $raw_result 85 | ); 86 | 87 | $expected_result = new CS_REST_Wrapper_Result($deserialised, $response_code); 88 | 89 | $this->setup_transport_and_serialisation($transport_result, $call_options, 90 | $deserialised, $raw_result, NULL, NULL, $response_code); 91 | 92 | $result = $this->wrapper->get($email); 93 | 94 | $this->assertIdentical($expected_result, $result); 95 | } 96 | 97 | 98 | function testdelete() { 99 | $raw_result = ''; 100 | $response_code = 200; 101 | $email = 'test@test.com'; 102 | 103 | $call_options = $this->get_call_options($this->admins_base_route.'.json?email='.urlencode($email), 'DELETE'); 104 | 105 | $transport_result = array ( 106 | 'code' => $response_code, 107 | 'response' => $raw_result 108 | ); 109 | 110 | $expected_result = new CS_REST_Wrapper_Result($raw_result, $response_code); 111 | 112 | $this->setup_transport_and_serialisation($transport_result, $call_options, 113 | $raw_result, $raw_result, NULL, NULL, $response_code); 114 | 115 | $result = $this->wrapper->delete($email); 116 | 117 | $this->assertIdentical($expected_result, $result); 118 | } 119 | } -------------------------------------------------------------------------------- /tests/csrest_events_test.php: -------------------------------------------------------------------------------- 1 | 'not a real api key'); 12 | } 13 | 14 | class CS_REST_OAuthTestEvents extends CS_REST_TestEvents { 15 | var $auth = array( 16 | 'access_token' => '7y872y3872i3eh', 17 | 'refresh_token' => 'kjw8qjd9ow8jo'); 18 | } 19 | 20 | abstract class CS_REST_TestEvents extends CS_REST_TestBase { 21 | var $client_id = 'fakeclientid'; 22 | var $events_base_route; 23 | var $event_type = "identify"; 24 | 25 | function set_up_inner() { 26 | $this->events_base_route = $this->base_route.'events/'.$this->client_id.'/'; 27 | $this->wrapper = new CS_REST_Events($this->auth, $this->client_id, $this->event_type, $this->protocol, 28 | $this->log_level, $this->api_host, $this->mock_log, 29 | $this->mock_serialiser, $this->mock_transport); 30 | } 31 | 32 | function testtrack() { 33 | $client_id = 'fakeclientid'; 34 | $raw_result = 'the new event id'; 35 | $email = 'test@email.com'; 36 | $event_name = 'Widget Man!'; 37 | $data = array('ExampleField'=> 'Me'); 38 | $anon_id = 'anonid-0'; 39 | $user_id = 'userid-0'; 40 | $response_code = 202; 41 | 42 | $call_options = $this->get_call_options($this->base_route.'events/'.$this->event_type.'/'.$this->client_id.'/track', 'POST'); 43 | 44 | // `Non-identify` event (custom, shopify) 45 | $event_info = array ( 46 | 'ContactID' => array( 47 | 'Email' => 'test@email.com', 48 | ), 49 | 'EventName' => $event_name, 50 | 'Data' => array( 51 | 'ExampleField'=> 'Me' 52 | ) 53 | ); 54 | 55 | if (strcmp($this->event_type, "identify") === 0) { 56 | // `Identify` event 57 | $event_info['ContactID']['AnonymousID'] = $anon_id; 58 | $event_info['ContactID']['UserID'] = $user_id; 59 | } 60 | 61 | $transport_result = array ( 62 | 'code' => $response_code, 63 | 'response' => $raw_result 64 | ); 65 | 66 | $expected_result = new CS_REST_Wrapper_Result($raw_result, $response_code); 67 | 68 | $call_options['data'] = 'event info was serialised to this'; 69 | 70 | $this->setup_transport_and_serialisation($transport_result, $call_options, 71 | $raw_result, $raw_result, 'event info was serialised to this', $event_info, $response_code); 72 | 73 | if (strcmp($this->event_type, "identify") == 0) { 74 | $result = $this->wrapper->track($email, $event_name, $anon_id, $user_id, $data); 75 | } else { 76 | $result = $this->wrapper->track($email, $event_name, NULL, NULL, $data); 77 | } 78 | 79 | $this->assertIdentical($expected_result, $result); 80 | 81 | } 82 | } -------------------------------------------------------------------------------- /tests/csrest_journey_emails_test.php: -------------------------------------------------------------------------------- 1 | 'not a real api key'); 12 | } 13 | 14 | class CS_REST_OAuthTestJourneyEmails extends CS_REST_TestJourneyEmails { 15 | var $auth = array( 16 | 'access_token' => '7y872y3872i3eh', 17 | 'refresh_token' => 'kjw8qjd9ow8jo'); 18 | } 19 | 20 | abstract class CS_REST_TestJourneyEmails extends CS_REST_TestBase { 21 | var $journey_email_id = 'not a real email id'; 22 | var $journey_emails_base_route; 23 | 24 | function set_up_inner() { 25 | $this->journey_emails_base_route = $this->base_route.'journeys/email/'.$this->journey_email_id.'/'; 26 | $this->wrapper = new CS_REST_JourneyEmails($this->journey_email_id, $this->auth, $this->protocol, $this->log_level, 27 | $this->api_host, $this->mock_log, $this->mock_serialiser, $this->mock_transport); 28 | 29 | } 30 | 31 | function testget_journey_recipients() { 32 | $raw_result = 'some recipients'; 33 | $since = '2021'; 34 | $response_code = 200; 35 | $deserialised = array('Recipient 1', 'Recipient 2'); 36 | $call_options = $this->get_call_options( 37 | $this->journey_emails_base_route.'opens.json?date='.$since); 38 | 39 | $transport_result = array ( 40 | 'code' => $response_code, 41 | 'response' => $raw_result 42 | ); 43 | 44 | $expected_result = new CS_REST_Wrapper_Result($deserialised, $response_code); 45 | 46 | $this->setup_transport_and_serialisation($transport_result, $call_options, 47 | $deserialised, $raw_result, NULL, NULL, $response_code); 48 | 49 | $result = $this->wrapper->get_journey_opens($since); 50 | 51 | $this->assertIdentical($expected_result, $result); 52 | 53 | 54 | } 55 | 56 | 57 | 58 | function testget_journey_opens() { 59 | $raw_result = 'some journey opens'; 60 | $since = '2021'; 61 | $response_code = 200; 62 | $deserialised = array('Journey Open 1', 'Journey Open 2'); 63 | $call_options = $this->get_call_options( 64 | $this->journey_emails_base_route.'opens.json?date='.$since); 65 | 66 | $transport_result = array ( 67 | 'code' => $response_code, 68 | 'response' => $raw_result 69 | ); 70 | 71 | $expected_result = new CS_REST_Wrapper_Result($deserialised, $response_code); 72 | 73 | $this->setup_transport_and_serialisation($transport_result, $call_options, 74 | $deserialised, $raw_result, NULL, NULL, $response_code); 75 | 76 | $result = $this->wrapper->get_journey_opens($since); 77 | 78 | $this->assertIdentical($expected_result, $result); 79 | } 80 | 81 | 82 | function testget_journey_clicks() { 83 | $raw_result = 'some journey clicks'; 84 | $since = '2021'; 85 | $response_code = 200; 86 | $deserialised = array('Journey Click 1', 'Journey Click 2'); 87 | $call_options = $this->get_call_options( 88 | $this->journey_emails_base_route.'clicks.json?date='.$since); 89 | 90 | $transport_result = array ( 91 | 'code' => $response_code, 92 | 'response' => $raw_result 93 | ); 94 | 95 | $expected_result = new CS_REST_Wrapper_Result($deserialised, $response_code); 96 | 97 | $this->setup_transport_and_serialisation($transport_result, $call_options, 98 | $deserialised, $raw_result, NULL, NULL, $response_code); 99 | 100 | $result = $this->wrapper->get_journey_clicks($since); 101 | 102 | $this->assertIdentical($expected_result, $result); 103 | } 104 | 105 | 106 | function testget_journey_unsubscribes() { 107 | $raw_result = 'some journey clicks'; 108 | $since = '2021'; 109 | $response_code = 200; 110 | $deserialised = array('Journey Unsub 1','Journey Unsub 2'); 111 | $call_options = $this->get_call_options( 112 | $this->journey_emails_base_route.'unsubscribes.json?date='.$since); 113 | 114 | $transport_result = array ( 115 | 'code' => $response_code, 116 | 'response' => $raw_result 117 | ); 118 | 119 | $expected_result = new CS_REST_Wrapper_Result($deserialised, $response_code); 120 | 121 | $this->setup_transport_and_serialisation($transport_result, $call_options, 122 | $deserialised, $raw_result, NULL, NULL, $response_code); 123 | 124 | $result = $this->wrapper->get_journey_unsubscribes($since); 125 | 126 | $this->assertIdentical($expected_result, $result); 127 | } 128 | 129 | 130 | 131 | function testget_journey_bounces() { 132 | $raw_result = 'some journey bounces'; 133 | $since = '2021'; 134 | $response_code = 200; 135 | $deserialised = array('Journey Bounce 1','Journey Bounce 2'); 136 | $call_options = $this->get_call_options( 137 | $this->journey_emails_base_route.'bounces.json?date='.$since); 138 | 139 | $transport_result = array ( 140 | 'code' => $response_code, 141 | 'response' => $raw_result 142 | ); 143 | 144 | $expected_result = new CS_REST_Wrapper_Result($deserialised, $response_code); 145 | 146 | $this->setup_transport_and_serialisation($transport_result, $call_options, 147 | $deserialised, $raw_result, NULL, NULL, $response_code); 148 | 149 | $result = $this->wrapper->get_journey_bounces($since); 150 | 151 | $this->assertIdentical($expected_result, $result); 152 | } 153 | 154 | 155 | 156 | 157 | 158 | 159 | } -------------------------------------------------------------------------------- /tests/csrest_journeys_test.php: -------------------------------------------------------------------------------- 1 | 'not a real api key'); 12 | } 13 | 14 | class CS_REST_OAuthTestJourneys extends CS_REST_TestJourneys { 15 | var $auth = array( 16 | 'access_token' => '7y872y3872i3eh', 17 | 'refresh_token' => 'kjw8qjd9ow8jo'); 18 | } 19 | 20 | abstract class CS_REST_TestJourneys extends CS_REST_TestBase { 21 | var $journey_id = 'not a real journey id'; 22 | var $journey_base_route; 23 | 24 | function set_up_inner() { 25 | $this->journey_base_route = $this->base_route.'journeys/'.$this->journey_id.'/'; 26 | $this->wrapper = new CS_REST_Journeys($this->journey_id, $this->auth, $this->protocol, $this->log_level, 27 | $this->api_host, $this->mock_log, $this->mock_serialiser, $this->mock_transport); 28 | 29 | } 30 | 31 | function testget_journey_summary() { 32 | 33 | $raw_result = 'journey details'; 34 | $deserialised = array(1,23,4,5); 35 | $call_options = $this->get_call_options(trim($this->journey_base_route, '/').'.json'); 36 | $this->general_test('get_journey_summary', $call_options, $raw_result, $deserialised); 37 | } 38 | } -------------------------------------------------------------------------------- /tests/csrest_people_test.php: -------------------------------------------------------------------------------- 1 | 'not a real api key'); 12 | } 13 | 14 | class CS_REST_OAuthTestPeople extends CS_REST_TestPeople { 15 | var $auth = array( 16 | 'access_token' => '7y872y3872i3eh', 17 | 'refresh_token' => 'kjw8qjd9ow8jo'); 18 | } 19 | 20 | abstract class CS_REST_TestPeople extends CS_REST_TestBase { 21 | var $client_id = 'not a real client id'; 22 | var $people_base_route; 23 | 24 | function set_up_inner() { 25 | $this->people_base_route = $this->base_route.'clients/'.$this->client_id . '/people'; 26 | $this->wrapper = new CS_REST_People($this->client_id, $this->auth, $this->protocol, $this->log_level, 27 | $this->api_host, $this->mock_log, $this->mock_serialiser, $this->mock_transport); 28 | } 29 | 30 | function testadd() { 31 | $raw_result = ''; 32 | 33 | $call_options = $this->get_call_options($this->people_base_route.'.json', 'POST'); 34 | 35 | $person = array ( 36 | 'EmailAddress' => 'test@test.com', 37 | 'Name' => 'Widget Man!', 38 | 'AccessLevel' => 0 39 | ); 40 | 41 | $this->general_test_with_argument('add', $person, $call_options, 42 | $raw_result, $raw_result, 'person was serialised to this'); 43 | } 44 | 45 | function testupdate() { 46 | $raw_result = ''; 47 | $email = 'test@test.com'; 48 | $serialised_person = 'subscriber data'; 49 | 50 | $call_options = $this->get_call_options( 51 | $this->people_base_route.'.json?email='.urlencode($email), 'PUT'); 52 | 53 | $person = array ( 54 | 'EmailAddress' => 'test2@test.com', 55 | 'Name' => 'Widget Man!', 56 | 'AccessLevel' => 0 57 | ); 58 | 59 | $transport_result = array ( 60 | 'code' => 200, 61 | 'response' => $raw_result 62 | ); 63 | 64 | $expected_result = new CS_REST_Wrapper_Result($raw_result, 200); 65 | $call_options['data'] = $serialised_person; 66 | 67 | $this->setup_transport_and_serialisation($transport_result, $call_options, 68 | $raw_result, $raw_result, $serialised_person, 69 | $person, 200); 70 | 71 | $result = $this->wrapper->update($email, $person); 72 | 73 | $this->assertIdentical($expected_result, $result); 74 | } 75 | 76 | function testget() { 77 | $raw_result = 'person details'; 78 | $deserialised = array(1,2,34,5); 79 | $response_code = 200; 80 | $email = 'test@test.com'; 81 | 82 | $call_options = $this->get_call_options( 83 | $this->people_base_route.'.json?email='.urlencode($email), 'GET'); 84 | 85 | $transport_result = array ( 86 | 'code' => $response_code, 87 | 'response' => $raw_result 88 | ); 89 | 90 | $expected_result = new CS_REST_Wrapper_Result($deserialised, $response_code); 91 | 92 | $this->setup_transport_and_serialisation($transport_result, $call_options, 93 | $deserialised, $raw_result, NULL, NULL, $response_code); 94 | 95 | $result = $this->wrapper->get($email); 96 | 97 | $this->assertIdentical($expected_result, $result); 98 | } 99 | 100 | 101 | function testdelete() { 102 | $raw_result = ''; 103 | $response_code = 200; 104 | $email = 'test@test.com'; 105 | 106 | $call_options = $this->get_call_options($this->people_base_route.'.json?email='.urlencode($email), 'DELETE'); 107 | 108 | $transport_result = array ( 109 | 'code' => $response_code, 110 | 'response' => $raw_result 111 | ); 112 | 113 | $expected_result = new CS_REST_Wrapper_Result($raw_result, $response_code); 114 | 115 | $this->setup_transport_and_serialisation($transport_result, $call_options, 116 | $raw_result, $raw_result, NULL, NULL, $response_code); 117 | 118 | $result = $this->wrapper->delete($email); 119 | 120 | $this->assertIdentical($expected_result, $result); 121 | } 122 | } -------------------------------------------------------------------------------- /tests/csrest_segments_test.php: -------------------------------------------------------------------------------- 1 | 'not a real api key'); 12 | } 13 | 14 | class CS_REST_OAuthTestSegments extends CS_REST_TestSegments { 15 | var $auth = array( 16 | 'access_token' => '7y872y3872i3eh', 17 | 'refresh_token' => 'kjw8qjd9ow8jo'); 18 | } 19 | 20 | abstract class CS_REST_TestSegments extends CS_REST_TestBase { 21 | var $segment_id = 'not a real segment id'; 22 | var $segment_base_route; 23 | 24 | function set_up_inner() { 25 | $this->segment_base_route = $this->base_route.'segments/'.$this->segment_id; 26 | $this->wrapper = new CS_REST_Segments($this->segment_id, $this->auth, $this->protocol, $this->log_level, 27 | $this->api_host, $this->mock_log, $this->mock_serialiser, $this->mock_transport); 28 | } 29 | 30 | function testcreate() { 31 | $raw_result = 'the new segment id'; 32 | $client_id = 'not a real list id'; 33 | $response_code = 201; 34 | 35 | $call_options = $this->get_call_options( 36 | $this->base_route.'segments/'.$client_id.'.json', 'POST'); 37 | 38 | $segment = array ( 39 | 'Title' => 'ABC Widgets Subscribers', 40 | 'RuleGroups' => array( 41 | array( 42 | 'Rules' => array( 43 | array( 44 | 'RuleType' => 'EmailAddress', 45 | 'Clause' => 'CONTAINS abcwidgets.com' 46 | ) 47 | ) 48 | ) 49 | ) 50 | ); 51 | 52 | $transport_result = array ( 53 | 'code' => $response_code, 54 | 'response' => $raw_result 55 | ); 56 | 57 | $expected_result = new CS_REST_Wrapper_Result($raw_result, $response_code); 58 | 59 | $call_options['data'] = 'segment was serialised to this'; 60 | $this->setup_transport_and_serialisation($transport_result, $call_options, 61 | $raw_result, $raw_result, 62 | 'segment was serialised to this', $segment, $response_code); 63 | 64 | $result = $this->wrapper->create($client_id, $segment); 65 | 66 | $this->assertIdentical($expected_result, $result); 67 | } 68 | 69 | function testupdate() { 70 | $raw_result = ''; 71 | 72 | $call_options = $this->get_call_options($this->segment_base_route.'.json', 'PUT'); 73 | 74 | $segment = array ( 75 | 'Title' => 'ABC Widgets Subscribers', 76 | 'RuleGroups' => array( 77 | array( 78 | 'Rules' => array( 79 | array( 80 | 'RuleType' => 'EmailAddress', 81 | 'Clause' => 'CONTAINS abcwidgets.com' 82 | ) 83 | ) 84 | ) 85 | ) 86 | ); 87 | 88 | $this->general_test_with_argument('update', $segment, $call_options, 89 | $raw_result, $raw_result, 'segment was serialised to this'); 90 | } 91 | 92 | function testadd_rulegroup() { 93 | $raw_result = ''; 94 | 95 | $call_options = $this->get_call_options($this->segment_base_route.'/rules.json', 'POST'); 96 | 97 | $rulegroup = array( 98 | 'Rules' => array( 99 | array( 100 | 'RuleType' => 'EmailAddress', 101 | 'Clause' => 'CONTAINS abcwidgets.com' 102 | ) 103 | ) 104 | ); 105 | 106 | $this->general_test_with_argument('add_rulegroup', $rulegroup, $call_options, 107 | $raw_result, $raw_result, 'rulegroup was serialised to this'); 108 | } 109 | 110 | function testget() { 111 | $raw_result = 'segment details'; 112 | $deserialised = array(1,23,4,5,6,7); 113 | $call_options = $this->get_call_options($this->segment_base_route.'.json'); 114 | 115 | $this->general_test('get', $call_options, $raw_result, $deserialised); 116 | } 117 | 118 | function testget_segment_subscribers() { 119 | $raw_result = 'some subscribers'; 120 | $segment_id = 'abc123'; 121 | $response_code = 200; 122 | $deserialised = array('Subscriber 1', 'Subscriber 2'); 123 | $tracking_pref = 'false'; 124 | 125 | $call_options = $this->get_call_options($this->segment_base_route.'/active.json?date=&includeTrackingPreference='.$tracking_pref); 126 | 127 | $transport_result = array ( 128 | 'code' => $response_code, 129 | 'response' => $raw_result 130 | ); 131 | 132 | $expected_result = new CS_REST_Wrapper_Result($deserialised, $response_code); 133 | 134 | $this->setup_transport_and_serialisation($transport_result, $call_options, 135 | $deserialised, $raw_result, NULL, NULL, $response_code); 136 | 137 | $result = $this->wrapper->get_subscribers('', null, null, null, null, false); 138 | 139 | $this->assertIdentical($expected_result, $result); 140 | } 141 | 142 | function testclear_rules() { 143 | $raw_result = ''; 144 | 145 | $call_options = $this->get_call_options($this->segment_base_route.'/rules.json', 'DELETE'); 146 | 147 | $this->general_test('clear_rules', $call_options, $raw_result, $raw_result); 148 | } 149 | 150 | function testdelete() { 151 | $raw_result = ''; 152 | 153 | $call_options = $this->get_call_options($this->segment_base_route.'.json', 'DELETE'); 154 | 155 | $this->general_test('delete', $call_options, $raw_result, $raw_result); 156 | } 157 | } -------------------------------------------------------------------------------- /tests/csrest_template_test.php: -------------------------------------------------------------------------------- 1 | 'not a real api key'); 12 | } 13 | 14 | class CS_REST_OAuthTestTemplates extends CS_REST_TestTemplates { 15 | var $auth = array( 16 | 'access_token' => '7y872y3872i3eh', 17 | 'refresh_token' => 'kjw8qjd9ow8jo'); 18 | } 19 | 20 | abstract class CS_REST_TestTemplates extends CS_REST_TestBase { 21 | var $template_id = 'not a real template id'; 22 | var $template_base_route; 23 | 24 | function set_up_inner() { 25 | $this->template_base_route = $this->base_route.'templates/'.$this->template_id; 26 | $this->wrapper = new CS_REST_Templates($this->template_id, $this->auth, $this->protocol, $this->log_level, 27 | $this->api_host, $this->mock_log, $this->mock_serialiser, $this->mock_transport); 28 | } 29 | 30 | function testcreate() { 31 | $raw_result = 'the new template id'; 32 | $client_id = 'not a real client id'; 33 | $response_code = 200; 34 | 35 | $call_options = $this->get_call_options( 36 | $this->base_route.'templates/'.$client_id.'.json', 'POST'); 37 | 38 | $template = array ( 39 | 'Name' => 'ABC Widgets', 40 | 'HtmlURL' => 'http://test.abc.net.au' 41 | ); 42 | 43 | $transport_result = array ( 44 | 'code' => $response_code, 45 | 'response' => $raw_result 46 | ); 47 | 48 | $expected_result = new CS_REST_Wrapper_Result($raw_result, $response_code); 49 | 50 | $call_options['data'] = 'template was serialised to this'; 51 | $this->setup_transport_and_serialisation($transport_result, $call_options, 52 | $raw_result, $raw_result, 53 | 'template was serialised to this', $template, $response_code); 54 | 55 | $result = $this->wrapper->create($client_id, $template); 56 | 57 | $this->assertIdentical($expected_result, $result); 58 | } 59 | 60 | function testupdate() { 61 | $raw_result = ''; 62 | 63 | $call_options = $this->get_call_options($this->template_base_route.'.json', 'PUT'); 64 | 65 | $template = array ( 66 | 'Name' => 'ABC Widgets', 67 | 'HtmlURL' => 'http://test.abc.net.au' 68 | ); 69 | 70 | $this->general_test_with_argument('update', $template, $call_options, 71 | $raw_result, $raw_result, 'template was serialised to this'); 72 | } 73 | 74 | function testget() { 75 | $raw_result = 'template details'; 76 | $deserialised = array(1,23,4,5,6,7); 77 | $call_options = $this->get_call_options($this->template_base_route.'.json'); 78 | 79 | $this->general_test('get', $call_options, $raw_result, $deserialised); 80 | } 81 | 82 | function testdelete() { 83 | $raw_result = ''; 84 | 85 | $call_options = $this->get_call_options($this->template_base_route.'.json', 'DELETE'); 86 | 87 | $this->general_test('delete', $call_options, $raw_result, $raw_result); 88 | } 89 | } -------------------------------------------------------------------------------- /tests/responses/active_subscribers.json: -------------------------------------------------------------------------------- 1 | { 2 | "Results": [ 3 | { 4 | "EmailAddress": "subs+7t8787Y@example.com", 5 | "Name": "Person One", 6 | "Date": "2010-10-25 10:28:00", 7 | "ListJoinedDate": "2010-10-25 10:28:00", 8 | "State": "Active", 9 | "CustomFields": [ 10 | { 11 | "Key": "website", 12 | "Value": "http://example.com" 13 | }, 14 | { 15 | "Key": "age", 16 | "Value": "24" 17 | }, 18 | { 19 | "Key": "subscription date", 20 | "Value": "2010-03-09" 21 | } 22 | ], 23 | "ReadsEmailWith": "Gmail" 24 | }, 25 | { 26 | "EmailAddress": "subs+7878787y8ggg@example.com", 27 | "Name": "Person Two", 28 | "Date": "2010-10-25 12:17:00", 29 | "ListJoinedDate": "2010-10-25 12:17:00", 30 | "State": "Active", 31 | "CustomFields": [ 32 | { 33 | "Key": "website", 34 | "Value": "http://subdomain.example.com" 35 | } 36 | ], 37 | "ReadsEmailWith": "Gmail" 38 | }, 39 | { 40 | "EmailAddress": "subs+7890909i0ggg@example.com", 41 | "Name": "Person Three", 42 | "Date": "2010-10-25 12:52:00", 43 | "ListJoinedDate": "2010-10-25 12:52:00", 44 | "State": "Active", 45 | "CustomFields": [ 46 | { 47 | "Key": "website", 48 | "Value": "http://subdomain.example.com" 49 | } 50 | ], 51 | "ReadsEmailWith": "" 52 | }, 53 | { 54 | "EmailAddress": "subs@example.com", 55 | "Name": "Person Four", 56 | "Date": "2010-10-27 13:13:00", 57 | "ListJoinedDate": "2010-10-27 13:13:00", 58 | "State": "Active", 59 | "CustomFields": [], 60 | "ReadsEmailWith": "" 61 | }, 62 | { 63 | "EmailAddress": "joey@example.com", 64 | "Name": "Person Five", 65 | "Date": "2010-10-27 13:13:00", 66 | "ListJoinedDate": "2010-10-27 13:13:00", 67 | "State": "Active", 68 | "CustomFields": [], 69 | "ReadsEmailWith": "Gmail" 70 | } 71 | ], 72 | "ResultsOrderedBy": "email", 73 | "OrderDirection": "asc", 74 | "PageNumber": 1, 75 | "PageSize": 1000, 76 | "RecordsOnThisPage": 5, 77 | "TotalNumberOfRecords": 5, 78 | "NumberOfPages": 1 79 | } -------------------------------------------------------------------------------- /tests/responses/add_subscriber.json: -------------------------------------------------------------------------------- 1 | "subscriber@example.com" -------------------------------------------------------------------------------- /tests/responses/apikey.json: -------------------------------------------------------------------------------- 1 | { 2 | "ApiKey": "981298u298ue98u219e8u2e98u2" 3 | } -------------------------------------------------------------------------------- /tests/responses/bounced_subscribers.json: -------------------------------------------------------------------------------- 1 | { 2 | "Results": [ 3 | { 4 | "EmailAddress": "bouncedsubscriber@example.com", 5 | "Name": "Bounced One", 6 | "Date": "2010-10-25 13:11:00", 7 | "ListJoinedDate": "2010-10-25 13:11:00", 8 | "State": "Bounced", 9 | "CustomFields": [], 10 | "ReadsEmailWith": "" 11 | } 12 | ], 13 | "ResultsOrderedBy": "email", 14 | "OrderDirection": "asc", 15 | "PageNumber": 1, 16 | "PageSize": 1000, 17 | "RecordsOnThisPage": 1, 18 | "TotalNumberOfRecords": 1, 19 | "NumberOfPages": 1 20 | } 21 | -------------------------------------------------------------------------------- /tests/responses/campaign_bounces.json: -------------------------------------------------------------------------------- 1 | { 2 | "Results": [ 3 | { 4 | "EmailAddress": "asdf@softbouncemyemail.com", 5 | "ListID": "654523a5855b4a440bae3fb295641546", 6 | "BounceType": "Soft", 7 | "Date": "2010-07-02 16:46:00", 8 | "Reason": "Bounce - But No Email Address Returned " 9 | }, 10 | { 11 | "EmailAddress": "asdf@hardbouncemyemail.com", 12 | "ListID": "654523a5855b4a440bae3fb295641546", 13 | "BounceType": "Soft", 14 | "Date": "2010-07-02 16:46:00", 15 | "Reason": "Soft Bounce - General" 16 | } 17 | ], 18 | "ResultsOrderedBy": "date", 19 | "OrderDirection": "asc", 20 | "PageNumber": 1, 21 | "PageSize": 1000, 22 | "RecordsOnThisPage": 2, 23 | "TotalNumberOfRecords": 2, 24 | "NumberOfPages": 1 25 | } -------------------------------------------------------------------------------- /tests/responses/campaign_clicks.json: -------------------------------------------------------------------------------- 1 | { 2 | "Results": [ 3 | { 4 | "EmailAddress": "subs+6576576576@example.com", 5 | "URL": "http://video.google.com.au/?hl=en&tab=wv", 6 | "ListID": "512a3bc577a58fdf689c654329b50fa0", 7 | "Date": "2010-10-11 08:29:00", 8 | "IPAddress": "192.168.126.87", 9 | "Latitude": -33.8683, 10 | "Longitude": 151.2086, 11 | "City": "Sydney", 12 | "Region": "New South Wales", 13 | "CountryCode": "AU", 14 | "CountryName": "Australia" 15 | }, 16 | { 17 | "EmailAddress": "subs+6576576576@example.com", 18 | "URL": "http://mail.google.com/mail/?hl=en&tab=wm", 19 | "ListID": "512a3bc577a58fdf689c654329b50fa0", 20 | "Date": "2010-10-11 08:29:00", 21 | "IPAddress": "192.168.126.87", 22 | "Latitude": -33.8683, 23 | "Longitude": 151.2086, 24 | "City": "Sydney", 25 | "Region": "New South Wales", 26 | "CountryCode": "AU", 27 | "CountryName": "Australia" 28 | }, 29 | { 30 | "EmailAddress": "subs+6576576576@example.com", 31 | "URL": "http://mail.google.com/mail/?hl=en&tab=wm", 32 | "ListID": "512a3bc577a58fdf689c654329b50fa0", 33 | "Date": "2010-10-06 17:24:00", 34 | "IPAddress": "192.168.126.87", 35 | "Latitude": -33.8683, 36 | "Longitude": 151.2086, 37 | "City": "Sydney", 38 | "Region": "New South Wales", 39 | "CountryCode": "AU", 40 | "CountryName": "Australia" 41 | } 42 | ], 43 | "ResultsOrderedBy": "date", 44 | "OrderDirection": "asc", 45 | "PageNumber": 1, 46 | "PageSize": 1000, 47 | "RecordsOnThisPage": 3, 48 | "TotalNumberOfRecords": 3, 49 | "NumberOfPages": 1 50 | } -------------------------------------------------------------------------------- /tests/responses/campaign_listsandsegments.json: -------------------------------------------------------------------------------- 1 | { 2 | "Lists": [ 3 | { 4 | "ListID": "a58ee1d3039b8bec838e6d1482a8a965", 5 | "Name": "List One" 6 | } 7 | ], 8 | "Segments": [ 9 | { 10 | "ListID": "2bea949d0bf96148c3e6a209d2e82060", 11 | "SegmentID": "dba84a225d5ce3d19105d7257baac46f", 12 | "Title": "Segment for campaign" 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /tests/responses/campaign_opens.json: -------------------------------------------------------------------------------- 1 | { 2 | "Results": [ 3 | { 4 | "EmailAddress": "subs+6576576576@example.com", 5 | "ListID": "512a3bc577a58fdf689c654329b50fa0", 6 | "Date": "2010-10-11 08:29:00", 7 | "IPAddress": "192.168.126.87", 8 | "Latitude": -33.8683, 9 | "Longitude": 151.2086, 10 | "City": "Sydney", 11 | "Region": "New South Wales", 12 | "CountryCode": "AU", 13 | "CountryName": "Australia" 14 | }, 15 | { 16 | "EmailAddress": "subs+6576576576@example.com", 17 | "ListID": "512a3bc577a58fdf689c654329b50fa0", 18 | "Date": "2010-10-08 14:24:00", 19 | "IPAddress": "192.168.126.87", 20 | "Latitude": -33.8683, 21 | "Longitude": 151.2086, 22 | "City": "Sydney", 23 | "Region": "New South Wales", 24 | "CountryCode": "AU", 25 | "CountryName": "Australia" 26 | }, 27 | { 28 | "EmailAddress": "subs+6576576576@example.com", 29 | "ListID": "512a3bc577a58fdf689c654329b50fa0", 30 | "Date": "2010-10-07 10:20:00", 31 | "IPAddress": "192.168.126.87", 32 | "Latitude": -33.8683, 33 | "Longitude": 151.2086, 34 | "City": "Sydney", 35 | "Region": "New South Wales", 36 | "CountryCode": "AU", 37 | "CountryName": "Australia" 38 | }, 39 | { 40 | "EmailAddress": "subs+6576576576@example.com", 41 | "ListID": "512a3bc577a58fdf689c654329b50fa0", 42 | "Date": "2010-10-07 07:15:00", 43 | "IPAddress": "192.168.126.87", 44 | "Latitude": -33.8683, 45 | "Longitude": 151.2086, 46 | "City": "Sydney", 47 | "Region": "New South Wales", 48 | "CountryCode": "AU", 49 | "CountryName": "Australia" 50 | }, 51 | { 52 | "EmailAddress": "subs+6576576576@example.com", 53 | "ListID": "512a3bc577a58fdf689c654329b50fa0", 54 | "Date": "2010-10-07 06:58:00", 55 | "IPAddress": "192.168.126.87", 56 | "Latitude": -33.8683, 57 | "Longitude": 151.2086, 58 | "City": "Sydney", 59 | "Region": "New South Wales", 60 | "CountryCode": "AU", 61 | "CountryName": "Australia" 62 | } 63 | ], 64 | "ResultsOrderedBy": "date", 65 | "OrderDirection": "asc", 66 | "PageNumber": 1, 67 | "PageSize": 1000, 68 | "RecordsOnThisPage": 5, 69 | "TotalNumberOfRecords": 5, 70 | "NumberOfPages": 1 71 | } -------------------------------------------------------------------------------- /tests/responses/campaign_recipients.json: -------------------------------------------------------------------------------- 1 | { 2 | "Results": [ 3 | { 4 | "EmailAddress": "subs+6g76t7t0@example.com", 5 | "ListID": "a994a3caf1328a16af9a69a730eaa706" 6 | }, 7 | { 8 | "EmailAddress": "subs+6g76t7t1@example.com", 9 | "ListID": "a994a3caf1328a16af9a69a730eaa706" 10 | }, 11 | { 12 | "EmailAddress": "subs+6g76t7t10@example.com", 13 | "ListID": "a994a3caf1328a16af9a69a730eaa706" 14 | }, 15 | { 16 | "EmailAddress": "subs+6g76t7t100@example.com", 17 | "ListID": "a994a3caf1328a16af9a69a730eaa706" 18 | }, 19 | { 20 | "EmailAddress": "subs+6g76t7t1000@example.com", 21 | "ListID": "a994a3caf1328a16af9a69a730eaa706" 22 | }, 23 | { 24 | "EmailAddress": "subs+6g76t7t1001@example.com", 25 | "ListID": "a994a3caf1328a16af9a69a730eaa706" 26 | }, 27 | { 28 | "EmailAddress": "subs+6g76t7t1002@example.com", 29 | "ListID": "a994a3caf1328a16af9a69a730eaa706" 30 | }, 31 | { 32 | "EmailAddress": "subs+6g76t7t1003@example.com", 33 | "ListID": "a994a3caf1328a16af9a69a730eaa706" 34 | }, 35 | { 36 | "EmailAddress": "subs+6g76t7t1004@example.com", 37 | "ListID": "a994a3caf1328a16af9a69a730eaa706" 38 | }, 39 | { 40 | "EmailAddress": "subs+6g76t7t1005@example.com", 41 | "ListID": "a994a3caf1328a16af9a69a730eaa706" 42 | }, 43 | { 44 | "EmailAddress": "subs+6g76t7t1006@example.com", 45 | "ListID": "a994a3caf1328a16af9a69a730eaa706" 46 | }, 47 | { 48 | "EmailAddress": "subs+6g76t7t1007@example.com", 49 | "ListID": "a994a3caf1328a16af9a69a730eaa706" 50 | }, 51 | { 52 | "EmailAddress": "subs+6g76t7t1008@example.com", 53 | "ListID": "a994a3caf1328a16af9a69a730eaa706" 54 | }, 55 | { 56 | "EmailAddress": "subs+6g76t7t1009@example.com", 57 | "ListID": "a994a3caf1328a16af9a69a730eaa706" 58 | }, 59 | { 60 | "EmailAddress": "subs+6g76t7t101@example.com", 61 | "ListID": "a994a3caf1328a16af9a69a730eaa706" 62 | }, 63 | { 64 | "EmailAddress": "subs+6g76t7t1010@example.com", 65 | "ListID": "a994a3caf1328a16af9a69a730eaa706" 66 | }, 67 | { 68 | "EmailAddress": "subs+6g76t7t1011@example.com", 69 | "ListID": "a994a3caf1328a16af9a69a730eaa706" 70 | }, 71 | { 72 | "EmailAddress": "subs+6g76t7t1012@example.com", 73 | "ListID": "a994a3caf1328a16af9a69a730eaa706" 74 | }, 75 | { 76 | "EmailAddress": "subs+6g76t7t1013@example.com", 77 | "ListID": "a994a3caf1328a16af9a69a730eaa706" 78 | }, 79 | { 80 | "EmailAddress": "subs+6g76t7t1014@example.com", 81 | "ListID": "a994a3caf1328a16af9a69a730eaa706" 82 | } 83 | ], 84 | "ResultsOrderedBy": "email", 85 | "OrderDirection": "asc", 86 | "PageNumber": 1, 87 | "PageSize": 20, 88 | "RecordsOnThisPage": 20, 89 | "TotalNumberOfRecords": 2200, 90 | "NumberOfPages": 110 91 | } -------------------------------------------------------------------------------- /tests/responses/campaign_spam.json: -------------------------------------------------------------------------------- 1 | { 2 | "Results": [ 3 | { 4 | "EmailAddress": "subs+6576576576@example.com", 5 | "ListID": "512a3bc577a58fdf689c654329b50fa0", 6 | "Date": "2010-10-11 08:29:00" 7 | } 8 | ], 9 | "ResultsOrderedBy": "date", 10 | "OrderDirection": "asc", 11 | "PageNumber": 1, 12 | "PageSize": 1000, 13 | "RecordsOnThisPage": 1, 14 | "TotalNumberOfRecords": 1, 15 | "NumberOfPages": 1 16 | } -------------------------------------------------------------------------------- /tests/responses/campaign_summary.json: -------------------------------------------------------------------------------- 1 | { 2 | "Name": "Campaign One", 3 | "Recipients": 5, 4 | "TotalOpened": 10, 5 | "Clicks": 0, 6 | "Unsubscribed": 0, 7 | "Bounced": 0, 8 | "UniqueOpened": 5, 9 | "WebVersionURL": "http://clientone.createsend.com/t/ViewEmail/r/3A433FC72FFE3B8B/C67FD2F38AC4859C/", 10 | "WebVersionTextURL": "http://createsend.com/t/r-3A433FC72FFE3B8B/t", 11 | "WorldviewURL": "http://clientone.createsend.com/reports/wv/r/3A433FC72FFE3B8B", 12 | "ForwardToAFriends": 18, 13 | "FacebookLikes": 25, 14 | "TwitterTweets": 11, 15 | "SpamComplaints": 23 16 | } -------------------------------------------------------------------------------- /tests/responses/campaign_unsubscribes.json: -------------------------------------------------------------------------------- 1 | { 2 | "Results": [ 3 | { 4 | "EmailAddress": "subs+6576576576@example.com", 5 | "ListID": "512a3bc577a58fdf689c654329b50fa0", 6 | "Date": "2010-10-11 08:29:00", 7 | "IPAddress": "192.168.126.87" 8 | } 9 | ], 10 | "ResultsOrderedBy": "date", 11 | "OrderDirection": "asc", 12 | "PageNumber": 1, 13 | "PageSize": 1000, 14 | "RecordsOnThisPage": 1, 15 | "TotalNumberOfRecords": 1, 16 | "NumberOfPages": 1 17 | } -------------------------------------------------------------------------------- /tests/responses/campaigns.json: -------------------------------------------------------------------------------- 1 | { 2 | "Results": [ 3 | { 4 | "WebVersionURL": "http://hello.createsend.com/t/ViewEmail/r/765E86829575EE2C/C67FD2F38AC4859C/", 5 | "WebVersionTextURL": "http://createsend.com/t/r-765E86829575EE2C/t", 6 | "CampaignID": "fc0ce7105baeaf97f47c99be31d02a91", 7 | "Subject": "Campaign One", 8 | "Name": "Campaign One", 9 | "FromName": "My Name", 10 | "FromEmail": "myemail@example.com", 11 | "ReplyTo": "myemail@example.com", 12 | "SentDate": "2010-10-12 12:58:00", 13 | "TotalRecipients": 2245, 14 | "Tags": ["Tag1", "Tag2"] 15 | }, 16 | { 17 | "WebVersionURL": "http://hello.createsend.com/t/ViewEmail/r/DD543566A87C9B8B/C67FD2F38AC4859C/", 18 | "WebVersionTextURL": "http://createsend.com/t/r-DD543566A87C9B8B/t", 19 | "CampaignID": "072472b88c853ae5dedaeaf549a8d607", 20 | "Subject": "Campaign Two", 21 | "Name": "Campaign Two", 22 | "FromName": "My Name", 23 | "FromEmail": "myemail@example.com", 24 | "ReplyTo": "myemail@example.com", 25 | "SentDate": "2010-10-06 16:20:00", 26 | "TotalRecipients": 11222, 27 | "Tags": [] 28 | } 29 | ], 30 | "ResultsOrderedBy": "SentDate", 31 | "OrderDirection": "desc", 32 | "PageNumber": 1, 33 | "PageSize": 2, 34 | "RecordsOnThisPage": 2, 35 | "TotalNumberOfRecords": 49, 36 | "NumberOfPages": 25 37 | } -------------------------------------------------------------------------------- /tests/responses/client_details.json: -------------------------------------------------------------------------------- 1 | { 2 | "ApiKey": "7c86c29e930f4a1c3836eb57e9e3f4b283b06857489a750e", 3 | "BasicDetails": { 4 | "ClientID": "4a397ccaaa55eb4e6aa1221e1e2d7122", 5 | "CompanyName": "Client One", 6 | "Country": "Australia", 7 | "TimeZone": "(GMT+10:00) Canberra, Melbourne, Sydney" 8 | }, 9 | "BillingDetails": { 10 | "CanPurchaseCredits": true, 11 | "MarkupOnDesignSpamTest": 0.0, 12 | "ClientPays": true, 13 | "BaseRatePerRecipient": 1.0, 14 | "MarkupPerRecipient": 0.0, 15 | "MarkupOnDelivery": 0.0, 16 | "BaseDeliveryRate": 5.0, 17 | "Currency": "USD", 18 | "BaseDesignSpamTestRate": 5.0 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/responses/clients.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "ClientID": "4a397ccaaa55eb4e6aa1221e1e2d7122", 4 | "Name": "Client One" 5 | }, 6 | { 7 | "ClientID": "a206def0582eec7dae47d937a4109cb2", 8 | "Name": "Client Two" 9 | } 10 | ] -------------------------------------------------------------------------------- /tests/responses/countries.json: -------------------------------------------------------------------------------- 1 | [ 2 | "Afghanistan", 3 | "Albania", 4 | "Algeria", 5 | "American Samoa", 6 | "Andorra", 7 | "Angola", 8 | "Anguilla", 9 | "Antigua & Barbuda", 10 | "Argentina" 11 | ] -------------------------------------------------------------------------------- /tests/responses/create_campaign.json: -------------------------------------------------------------------------------- 1 | "787y87y87y87y87y87y87" -------------------------------------------------------------------------------- /tests/responses/create_client.json: -------------------------------------------------------------------------------- 1 | "32a381c49a2df99f1d0c6f3c112352b9" -------------------------------------------------------------------------------- /tests/responses/create_custom_field.json: -------------------------------------------------------------------------------- 1 | "[newdatefield]" -------------------------------------------------------------------------------- /tests/responses/create_list.json: -------------------------------------------------------------------------------- 1 | "e3c5f034d68744f7881fdccf13c2daee" -------------------------------------------------------------------------------- /tests/responses/create_list_webhook.json: -------------------------------------------------------------------------------- 1 | "6a783d359bd44ef62c6ca0d3eda4412a" -------------------------------------------------------------------------------- /tests/responses/create_segment.json: -------------------------------------------------------------------------------- 1 | "0246c2aea610a3545d9780bf6ab89006" -------------------------------------------------------------------------------- /tests/responses/create_template.json: -------------------------------------------------------------------------------- 1 | "98y2e98y289dh89h938389" -------------------------------------------------------------------------------- /tests/responses/custom_api_error.json: -------------------------------------------------------------------------------- 1 | { 2 | "Code": 98798, 3 | "Message": "A crazy API error" 4 | } -------------------------------------------------------------------------------- /tests/responses/custom_fields.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "FieldName": "website", 4 | "Key": "[website]", 5 | "DataType": "Text", 6 | "FieldOptions": [], 7 | "VisibleInPreferenceCenter": true 8 | }, 9 | { 10 | "FieldName": "age", 11 | "Key": "[age]", 12 | "DataType": "Number", 13 | "FieldOptions": [], 14 | "VisibleInPreferenceCenter": true 15 | }, 16 | { 17 | "FieldName": "subscription date", 18 | "Key": "[subscriptiondate]", 19 | "DataType": "Date", 20 | "FieldOptions": [], 21 | "VisibleInPreferenceCenter": false 22 | } 23 | ] -------------------------------------------------------------------------------- /tests/responses/deleted_subscribers.json: -------------------------------------------------------------------------------- 1 | { 2 | "Results": [ 3 | { 4 | "EmailAddress": "subs+7t8787Y@example.com", 5 | "Name": "Person One", 6 | "Date": "2010-10-25 10:28:00", 7 | "ListJoinedDate": "2010-10-25 10:28:00", 8 | "State": "Deleted", 9 | "CustomFields": [ 10 | { 11 | "Key": "website", 12 | "Value": "http://example.com" 13 | }, 14 | { 15 | "Key": "age", 16 | "Value": "24" 17 | }, 18 | { 19 | "Key": "subscription date", 20 | "Value": "2010-03-09" 21 | } 22 | ], 23 | "ReadsEmailWith": "Gmail" 24 | }, 25 | { 26 | "EmailAddress": "subs+7878787y8ggg@example.com", 27 | "Name": "Person Two", 28 | "Date": "2010-10-25 12:17:00", 29 | "ListJoinedDate": "2010-10-25 10:28:00", 30 | "State": "Deleted", 31 | "CustomFields": [ 32 | { 33 | "Key": "website", 34 | "Value": "http://subdomain.example.com" 35 | } 36 | ], 37 | "ReadsEmailWith": "Gmail" 38 | }, 39 | { 40 | "EmailAddress": "subs+7890909i0ggg@example.com", 41 | "Name": "Person Three", 42 | "Date": "2010-10-25 12:52:00", 43 | "ListJoinedDate": "2010-10-25 10:28:00", 44 | "State": "Deleted", 45 | "CustomFields": [ 46 | { 47 | "Key": "website", 48 | "Value": "http://subdomain.example.com" 49 | } 50 | ], 51 | "ReadsEmailWith": "" 52 | }, 53 | { 54 | "EmailAddress": "subs@example.com", 55 | "Name": "Person Four", 56 | "Date": "2010-10-27 13:13:00", 57 | "ListJoinedDate": "2010-10-25 10:28:00", 58 | "State": "Deleted", 59 | "CustomFields": [], 60 | "ReadsEmailWith": "" 61 | }, 62 | { 63 | "EmailAddress": "joey@example.com", 64 | "Name": "Person Five", 65 | "Date": "2010-10-27 13:13:00", 66 | "ListJoinedDate": "2010-10-25 10:28:00", 67 | "State": "Deleted", 68 | "CustomFields": [], 69 | "ReadsEmailWith": "Gmail" 70 | } 71 | ], 72 | "ResultsOrderedBy": "email", 73 | "OrderDirection": "asc", 74 | "PageNumber": 1, 75 | "PageSize": 1000, 76 | "RecordsOnThisPage": 5, 77 | "TotalNumberOfRecords": 5, 78 | "NumberOfPages": 1 79 | } -------------------------------------------------------------------------------- /tests/responses/drafts.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "CampaignID": "7c7424792065d92627139208c8c01db1", 4 | "Name": "Draft One", 5 | "Subject": "Draft One", 6 | "FromName": "My Name", 7 | "FromEmail": "myemail@example.com", 8 | "ReplyTo": "myemail@example.com", 9 | "DateCreated": "2010-08-19 16:08:00", 10 | "PreviewURL": "http://hello.createsend.com/t/ViewEmail/r/E97A7BB2E6983DA1/C67FD2F38AC4859C/", 11 | "PreviewTextURL": "http://createsend.com/t/r-E97A7BB2E6983DA1/t", 12 | "Tags": [] 13 | }, 14 | { 15 | "CampaignID": "2e928e982065d92627139208c8c01db1", 16 | "Name": "Draft Two", 17 | "Subject": "Draft Two", 18 | "FromName": "My Name", 19 | "FromEmail": "myemail@example.com", 20 | "ReplyTo": "myemail@example.com", 21 | "DateCreated": "2010-08-19 16:08:00", 22 | "PreviewURL": "http://hello.createsend.com/t/ViewEmail/r/E97A7BB2E6983DA1/C67FD2F38AC4859C/", 23 | "PreviewTextURL": "http://createsend.com/t/r-E97A7BB2E6983DA1/t", 24 | "Tags": ["Tag1", "Tag2"] 25 | } 26 | ] -------------------------------------------------------------------------------- /tests/responses/import_subscribers.json: -------------------------------------------------------------------------------- 1 | { 2 | "FailureDetails": [], 3 | "TotalUniqueEmailsSubmitted": 3, 4 | "TotalExistingSubscribers": 0, 5 | "TotalNewSubscribers": 3, 6 | "DuplicateEmailsInSubmission": [] 7 | } -------------------------------------------------------------------------------- /tests/responses/import_subscribers_partial_success.json: -------------------------------------------------------------------------------- 1 | { 2 | "ResultData": { 3 | "TotalUniqueEmailsSubmitted": 3, 4 | "TotalExistingSubscribers": 2, 5 | "TotalNewSubscribers": 0, 6 | "DuplicateEmailsInSubmission": [], 7 | "FailureDetails": [ 8 | { 9 | "EmailAddress": "example+1@example", 10 | "Code": 1, 11 | "Message": "Invalid Email Address" 12 | } 13 | ] 14 | }, 15 | "Code": 210, 16 | "Message": "Subscriber Import had some failures" 17 | } -------------------------------------------------------------------------------- /tests/responses/journey_details.json: -------------------------------------------------------------------------------- 1 | { 2 | "JourneyID": "183e5a8818d6202e95f1fa747b924226", 3 | "Name": "welcome active folks", 4 | "TriggerType": "Enters Segment", 5 | "Status": "Active", 6 | "Emails": [ 7 | { 8 | "EmailID": "383ec87ea1129ebc5e539a2db35c3200", 9 | "Name": "email", 10 | "Bounced": 0, 11 | "Clicked": 0, 12 | "Opened": 1, 13 | "Sent": 14, 14 | "UniqueOpened": 1, 15 | "Unsubscribed": 0 16 | } 17 | ] 18 | } -------------------------------------------------------------------------------- /tests/responses/journeys.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "ListID": "abcabcabcacbabcabcabcabcabc", 4 | "JourneyID": "12345678901234567890", 5 | "Name": "Journey One", 6 | "Status": "Active" 7 | }, 8 | { 9 | "ListID": "defdefdedefdefdefdefdefdefdef", 10 | "JourneyID": "09876543210987654321", 11 | "Name": "Journey Two", 12 | "Status": "Active" 13 | } 14 | ] -------------------------------------------------------------------------------- /tests/responses/list_details.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConfirmedOptIn": false, 3 | "Title": "a non-basic list :)", 4 | "UnsubscribePage": "", 5 | "ListID": "2fe4c8f0373ce320e2200596d7ef168f", 6 | "ConfirmationSuccessPage": "", 7 | "UnsubscribeSetting": "AllClientLists" 8 | } -------------------------------------------------------------------------------- /tests/responses/list_stats.json: -------------------------------------------------------------------------------- 1 | { 2 | "TotalActiveSubscribers": 6, 3 | "NewActiveSubscribersToday": 0, 4 | "NewActiveSubscribersYesterday": 8, 5 | "NewActiveSubscribersThisWeek": 8, 6 | "NewActiveSubscribersThisMonth": 8, 7 | "NewActiveSubscribersThisYear": 8, 8 | "TotalUnsubscribes": 2, 9 | "UnsubscribesToday": 0, 10 | "UnsubscribesYesterday": 2, 11 | "UnsubscribesThisWeek": 2, 12 | "UnsubscribesThisMonth": 2, 13 | "UnsubscribesThisYear": 2, 14 | "TotalDeleted": 0, 15 | "DeletedToday": 0, 16 | "DeletedYesterday": 0, 17 | "DeletedThisWeek": 0, 18 | "DeletedThisMonth": 0, 19 | "DeletedThisYear": 0, 20 | "TotalBounces": 0, 21 | "BouncesToday": 0, 22 | "BouncesYesterday": 0, 23 | "BouncesThisWeek": 0, 24 | "BouncesThisMonth": 0, 25 | "BouncesThisYear": 0 26 | } -------------------------------------------------------------------------------- /tests/responses/list_webhooks.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "WebhookID": "943678317049bc13", 4 | "Events": [ 5 | "Bounce", 6 | "Spam" 7 | ], 8 | "Url": "http://www.postbin.org/d9w8ud9wud9w", 9 | "Status": "Active", 10 | "PayloadFormat": "Json" 11 | }, 12 | { 13 | "WebhookID": "ee1b3864e5ca6161", 14 | "Events": [ 15 | "Subscribe" 16 | ], 17 | "Url": "http://www.postbin.org/hiuhiu2h2u", 18 | "Status": "Active", 19 | "PayloadFormat": "Xml" 20 | } 21 | ] -------------------------------------------------------------------------------- /tests/responses/lists.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "ListID": "a58ee1d3039b8bec838e6d1482a8a965", 4 | "Name": "List One" 5 | }, 6 | { 7 | "ListID": "99bc35084a5739127a8ab81eae5bd305", 8 | "Name": "List Two" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /tests/responses/listsforemail.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "ListID": "ab4a2b57c7c8f1ba62f898a1af1a575b", 4 | "ListName": "List Number One", 5 | "SubscriberState": "Active", 6 | "DateSubscriberAdded": "2012-08-20 22:32:00" 7 | }, 8 | { 9 | "ListID": "d8e59b07138cf1316a6587007c443e21", 10 | "ListName": "List Number Two", 11 | "SubscriberState": "Unsubscribed", 12 | "DateSubscriberAdded": "2012-08-21 01:35:00" 13 | } 14 | ] -------------------------------------------------------------------------------- /tests/responses/oauth_exchange_token.json: -------------------------------------------------------------------------------- 1 | { 2 | "access_token": "SlAV32hkKG", 3 | "expires_in": 1209600, 4 | "refresh_token": "tGzv3JOkF0XG5Qx2TlKWIA" 5 | } -------------------------------------------------------------------------------- /tests/responses/scheduled.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "DateScheduled": "2011-05-25 10:40:00", 4 | "ScheduledTimeZone": "(GMT+10:00) Canberra, Melbourne, Sydney", 5 | "CampaignID": "827dbbd2161ea9989fa11ad562c66937", 6 | "Name": "Magic Issue One", 7 | "Subject": "Magic Issue One", 8 | "FromName": "My Name", 9 | "FromEmail": "myemail@example.com", 10 | "ReplyTo": "myemail@example.com", 11 | "DateCreated": "2011-05-24 10:37:00", 12 | "PreviewURL": "http://createsend.com/t/r-DD543521A87C9B8B", 13 | "PreviewTextURL": "http://createsend.com/t/r-DD543521A87C9B8B/t", 14 | "Tags": ["Tag1", "Tag2"] 15 | }, 16 | { 17 | "DateScheduled": "2011-05-29 11:20:00", 18 | "ScheduledTimeZone": "(GMT+10:00) Canberra, Melbourne, Sydney", 19 | "CampaignID": "4f54bbd2161e65789fa11ad562c66937", 20 | "Name": "Magic Issue Two", 21 | "Subject": "Magic Issue Two", 22 | "FromName": "My Name", 23 | "FromEmail": "myemail@example.com", 24 | "ReplyTo": "myemail@example.com", 25 | "DateCreated": "2011-05-24 10:39:00", 26 | "PreviewURL": "http://createsend.com/t/r-DD913521A87C9B8B", 27 | "PreviewTextURL": "http://createsend.com/t/r-DD913521A87C9B8B/t", 28 | "Tags": [] 29 | } 30 | ] -------------------------------------------------------------------------------- /tests/responses/segment_details.json: -------------------------------------------------------------------------------- 1 | { 2 | "ActiveSubscribers": 0, 3 | "RuleGroups": [ 4 | { 5 | "Rules": [ 6 | { 7 | "RuleType": "EmailAddress", 8 | "Clause": "CONTAINS @hello.com" 9 | }, 10 | { 11 | "RuleType": "Name", 12 | "Clause": "PROVIDED" 13 | } 14 | ] 15 | } 16 | ], 17 | "ListID": "2bea949d0bf96148c3e6a209d2e82060", 18 | "SegmentID": "dba84a225d5ce3d19105d7257baac46f", 19 | "Title": "My Segment" 20 | } -------------------------------------------------------------------------------- /tests/responses/segment_subscribers.json: -------------------------------------------------------------------------------- 1 | { 2 | "Results": [ 3 | { 4 | "EmailAddress": "personone@example.com", 5 | "Name": "Person One", 6 | "Date": "2010-10-27 13:13:00", 7 | "ListJoinedDate": "2010-10-27 13:13:00", 8 | "State": "Active", 9 | "CustomFields": [] 10 | }, 11 | { 12 | "EmailAddress": "persontwo@example.com", 13 | "Name": "Person Two", 14 | "Date": "2010-10-27 13:13:00", 15 | "ListJoinedDate": "2010-10-27 13:13:00", 16 | "State": "Active", 17 | "CustomFields": [] 18 | } 19 | ], 20 | "ResultsOrderedBy": "email", 21 | "OrderDirection": "asc", 22 | "PageNumber": 1, 23 | "PageSize": 1000, 24 | "RecordsOnThisPage": 2, 25 | "TotalNumberOfRecords": 2, 26 | "NumberOfPages": 1 27 | } -------------------------------------------------------------------------------- /tests/responses/segments.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "ListID": "a58ee1d3039b8bec838e6d1482a8a965", 4 | "SegmentID": "46aa5e01fd43381863d4e42cf277d3a9", 5 | "Title": "Segment One" 6 | }, 7 | { 8 | "ListID": "8dffb94c60c5faa3d40f496f2aa58a8a", 9 | "SegmentID": "dhw9q8jd9q8wd09quw0d909wid9i09iq", 10 | "Title": "Segment Two" 11 | } 12 | ] -------------------------------------------------------------------------------- /tests/responses/subscriber_details.json: -------------------------------------------------------------------------------- 1 | { 2 | "EmailAddress": "subscriber@example.com", 3 | "Name": "Subscriber One", 4 | "Date": "2010-10-25 10:28:00", 5 | "ListJoinedDate": "2010-10-25 10:28:00", 6 | "State": "Active", 7 | "CustomFields": [ 8 | { 9 | "Key": "website", 10 | "Value": "http://example.com" 11 | }, 12 | { 13 | "Key": "age", 14 | "Value": "24" 15 | }, 16 | { 17 | "Key": "subscription date", 18 | "Value": "2010-03-09" 19 | } 20 | ], 21 | "ReadsEmailWith": "Gmail" 22 | } -------------------------------------------------------------------------------- /tests/responses/subscriber_history.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "ID": "fc0ce7105baeaf97f47c99be31d02a91", 4 | "Type": "Campaign", 5 | "Name": "Campaign One", 6 | "Actions": [ 7 | { 8 | "Event": "Open", 9 | "Date": "2010-10-12 13:18:00", 10 | "IPAddress": "192.168.126.87", 11 | "Detail": "" 12 | }, 13 | { 14 | "Event": "Click", 15 | "Date": "2010-10-12 13:16:00", 16 | "IPAddress": "192.168.126.87", 17 | "Detail": "http://example.com/post/12323/" 18 | }, 19 | { 20 | "Event": "Click", 21 | "Date": "2010-10-12 13:15:00", 22 | "IPAddress": "192.168.126.87", 23 | "Detail": "http://example.com/post/29889/" 24 | }, 25 | { 26 | "Event": "Open", 27 | "Date": "2010-10-12 13:15:00", 28 | "IPAddress": "192.168.126.87", 29 | "Detail": "" 30 | }, 31 | { 32 | "Event": "Click", 33 | "Date": "2010-10-12 13:01:00", 34 | "IPAddress": "192.168.126.87", 35 | "Detail": "http://example.com/post/82211/" 36 | }, 37 | { 38 | "Event": "Open", 39 | "Date": "2010-10-12 13:01:00", 40 | "IPAddress": "192.168.126.87", 41 | "Detail": "" 42 | } 43 | ] 44 | } 45 | ] -------------------------------------------------------------------------------- /tests/responses/suppressionlist.json: -------------------------------------------------------------------------------- 1 | { 2 | "Results": [ 3 | { 4 | "SuppressionReason": "Unsubscribed", 5 | "EmailAddress": "example+1@example.com", 6 | "Date": "2010-10-26 10:55:31", 7 | "State": "Suppressed" 8 | }, 9 | { 10 | "SuppressionReason": "Unsubscribed", 11 | "EmailAddress": "example+2@example.com", 12 | "Date": "2010-10-26 10:55:31", 13 | "State": "Suppressed" 14 | }, 15 | { 16 | "SuppressionReason": "Unsubscribed", 17 | "EmailAddress": "example+3@example.com", 18 | "Date": "2010-10-26 10:55:31", 19 | "State": "Suppressed" 20 | }, 21 | { 22 | "SuppressionReason": "Unsubscribed", 23 | "EmailAddress": "subscriber@example.com", 24 | "Date": "2010-10-25 13:11:04", 25 | "State": "Suppressed" 26 | }, 27 | { 28 | "SuppressionReason": "Unsubscribed", 29 | "EmailAddress": "subscriberone@example.com", 30 | "Date": "2010-10-25 13:04:15", 31 | "State": "Suppressed" 32 | } 33 | ], 34 | "ResultsOrderedBy": "email", 35 | "OrderDirection": "asc", 36 | "PageNumber": 1, 37 | "PageSize": 1000, 38 | "RecordsOnThisPage": 5, 39 | "TotalNumberOfRecords": 5, 40 | "NumberOfPages": 1 41 | } -------------------------------------------------------------------------------- /tests/responses/systemdate.json: -------------------------------------------------------------------------------- 1 | { 2 | "SystemDate": "2010-10-15 09:27:00" 3 | } -------------------------------------------------------------------------------- /tests/responses/tags.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "Name": "Tag One", 4 | "NumberOfCampaigns": "120" 5 | }, 6 | { 7 | "Name": "Tag Two", 8 | "NumberOfCampaigns": "62" 9 | } 10 | ] -------------------------------------------------------------------------------- /tests/responses/template_details.json: -------------------------------------------------------------------------------- 1 | { 2 | "TemplateID": "98y2e98y289dh89h938389", 3 | "Name": "Template One", 4 | "PreviewURL": "http://preview.createsend.com/createsend/templates/previewTemplate.aspx?ID=01AF532CD8889B33&d=r&c=E816F55BFAD1A753", 5 | "ScreenshotURL": "http://preview.createsend.com/ts/r/14/833/263/14833263.jpg?0318092600" 6 | } -------------------------------------------------------------------------------- /tests/responses/templates.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "TemplateID": "5cac213cf061dd4e008de5a82b7a3621", 4 | "Name": "Template One", 5 | "PreviewURL": "http://preview.createsend.com/createsend/templates/previewTemplate.aspx?ID=01AF532CD8889B33&d=r&c=E816F55BFAD1A753", 6 | "ScreenshotURL": "http://preview.createsend.com/ts/r/14/833/263/14833263.jpg?0318092541" 7 | }, 8 | { 9 | "TemplateID": "da645c271bc85fb6550acff937c2ab2e", 10 | "Name": "Template Two", 11 | "PreviewURL": "http://preview.createsend.com/createsend/templates/previewTemplate.aspx?ID=C8A180629495E798&d=r&c=E816F55BFAD1A753", 12 | "ScreenshotURL": "http://preview.createsend.com/ts/r/18/7B3/552/187B3552.jpg?0705043527" 13 | } 14 | ] -------------------------------------------------------------------------------- /tests/responses/timezones.json: -------------------------------------------------------------------------------- 1 | [ 2 | "(GMT) Casablanca", 3 | "(GMT) Coordinated Universal Time", 4 | "(GMT) Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London", 5 | "(GMT) Monrovia, Reykjavik", 6 | "(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna", 7 | "(GMT+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague", 8 | "(GMT+01:00) Brussels, Copenhagen, Madrid, Paris" 9 | ] -------------------------------------------------------------------------------- /tests/responses/unconfirmed_subscribers.json: -------------------------------------------------------------------------------- 1 | { 2 | "Results": [ 3 | { 4 | "EmailAddress": "subs+7878787y8ggg@example.com", 5 | "Name": "Person Two", 6 | "Date": "2010-10-25 12:17:00", 7 | "ListJoinedDate": "2010-10-25 10:28:00", 8 | "State": "Unconfirmed", 9 | "CustomFields": [ 10 | { 11 | "Key": "website", 12 | "Value": "http://subdomain.example.com" 13 | } 14 | ], 15 | "ReadsEmailWith": "Gmail" 16 | }, 17 | { 18 | "EmailAddress": "subs+7890909i0ggg@example.com", 19 | "Name": "Person Three", 20 | "Date": "2010-10-25 12:52:00", 21 | "ListJoinedDate": "2010-10-25 10:28:00", 22 | "State": "Unconfirmed", 23 | "CustomFields": [ 24 | { 25 | "Key": "website", 26 | "Value": "http://subdomain.example.com" 27 | } 28 | ], 29 | "ReadsEmailWith": "" 30 | } 31 | ], 32 | "ResultsOrderedBy": "email", 33 | "OrderDirection": "asc", 34 | "PageNumber": 1, 35 | "PageSize": 1000, 36 | "RecordsOnThisPage": 2, 37 | "TotalNumberOfRecords": 2, 38 | "NumberOfPages": 1 39 | } -------------------------------------------------------------------------------- /tests/responses/unsubscribed_subscribers.json: -------------------------------------------------------------------------------- 1 | { 2 | "Results": [ 3 | { 4 | "EmailAddress": "subscriber@example.com", 5 | "Name": "Unsub One", 6 | "Date": "2010-10-25 13:11:00", 7 | "ListJoinedDate": "2010-10-25 13:11:00", 8 | "State": "Unsubscribed", 9 | "CustomFields": [] 10 | }, 11 | { 12 | "EmailAddress": "subscriberone@example.com", 13 | "Name": "Subscriber", 14 | "Date": "2010-10-25 13:04:00", 15 | "ListJoinedDate": "2010-10-25 13:04:00", 16 | "State": "Unsubscribed", 17 | "CustomFields": [ 18 | { 19 | "Key": "website", 20 | "Value": "http://google.com" 21 | } 22 | ] 23 | }, 24 | { 25 | "EmailAddress": "example+1@example.com", 26 | "Name": "Example One", 27 | "Date": "2010-10-26 10:56:00", 28 | "ListJoinedDate": "2010-10-26 10:56:00", 29 | "State": "Unsubscribed", 30 | "CustomFields": [] 31 | }, 32 | { 33 | "EmailAddress": "example+2@example.com", 34 | "Name": "Example Two", 35 | "Date": "2010-10-26 10:56:00", 36 | "ListJoinedDate": "2010-10-26 10:56:00", 37 | "State": "Unsubscribed", 38 | "CustomFields": [] 39 | }, 40 | { 41 | "EmailAddress": "example+3@example.com", 42 | "Name": "Example Three", 43 | "Date": "2010-10-26 10:56:00", 44 | "ListJoinedDate": "2010-10-26 10:56:00", 45 | "State": "Unsubscribed", 46 | "CustomFields": [] 47 | } 48 | ], 49 | "ResultsOrderedBy": "email", 50 | "OrderDirection": "asc", 51 | "PageNumber": 1, 52 | "PageSize": 1000, 53 | "RecordsOnThisPage": 5, 54 | "TotalNumberOfRecords": 5, 55 | "NumberOfPages": 1 56 | } --------------------------------------------------------------------------------