<?php require_once '../../csrest_campaigns.php'; $wrap = new CS_REST_Campaigns(NULL, 'Your API Key'); $result = $wrap->create('Campaigns Client ID', array('Subject' => 'Campaign Subject', 'Name' => 'Campaign Name', 'FromName' => 'Campaign From Name', 'FromEmail' => 'Campaign From Email Address', 'ReplyTo' => 'Campaign Reply To Email Address', 'HtmlUrl' => 'Campaign HTML Import URL', 'TextUrl' => 'Campaign Text Import URL', 'ListIDs' => array('First List', 'Second List'), 'SegmentIDs' => array('First Segment', 'Second Segment'))); echo "Result of POST /api/v3/campaigns/{clientID}\n<br />"; if ($result->was_successful()) { echo "Created with ID\n<br />" . $result->response; } else { echo 'Failed with code ' . $result->http_status_code . "\n<br /><pre>"; var_dump($result->response); echo '</pre>'; }
<?php require_once '../../csrest_campaigns.php'; $auth = array('access_token' => 'your access token', 'refresh_token' => 'your refresh token'); $wrap = new CS_REST_Campaigns('Campaign ID to unschedule', $auth); $result = $wrap->unschedule(); echo "Result of POST /api/v3.1/campaigns/{id}/unschedule\n<br />"; if ($result->was_successful()) { echo "Scheduled with code\n<br />" . $result->http_status_code; } else { echo 'Failed with code ' . $result->http_status_code . "\n<br /><pre>"; var_dump($result->response); echo '</pre>'; }
<?php require_once '../../csrest_campaigns.php'; $auth = array('access_token' => 'your access token', 'refresh_token' => 'your refresh token'); $wrap = new CS_REST_Campaigns('Campaign ID to get recipients for', $auth); $result = $wrap->get_recipients(1, 50, 'email', 'asc'); //$result = $wrap->get_recipients(page number, page size, order by, order direction); echo "Result of GET /api/v3.1/campaigns/{id}/recipients\n<br />"; if ($result->was_successful()) { echo "Got recipients\n<br /><pre>"; var_dump($result->response); } else { echo 'Failed with code ' . $result->http_status_code . "\n<br /><pre>"; var_dump($result->response); } echo '</pre>';
<?php require_once '../../csrest_campaigns.php'; $auth = array('access_token' => 'your access token', 'refresh_token' => 'your refresh token'); $wrap = new CS_REST_Campaigns('Campaign ID to get bounces for', $auth); $result = $wrap->get_bounces('Get bounces since', 1, 50, 'email', 'asc'); //$result = $wrap->get_bounces(page, page size, order field, order direction); echo "Result of GET /api/v3.1/campaigns/{id}/bounces\n<br />"; if ($result->was_successful()) { echo "Got bounces\n<br /><pre>"; var_dump($result->response); } else { echo 'Failed with code ' . $result->http_status_code . "\n<br /><pre>"; var_dump($result->response); } echo '</pre>';
<?php require_once '../../csrest_campaigns.php'; $auth = array('access_token' => 'your access token', 'refresh_token' => 'your refresh token'); $wrap = new CS_REST_Campaigns('Campaign ID to get lists for', $auth); $result = $wrap->get_lists_and_segments(); echo "Result of GET /api/v3.1/campaigns/{id}/listsandsegments\n<br />"; if ($result->was_successful()) { echo "Got lists and segments\n<br /><pre>"; var_dump($result->response); } else { echo 'Failed with code ' . $result->http_status_code . "\n<br /><pre>"; var_dump($result->response); } echo '</pre>';
<?php require_once '../../csrest_campaigns.php'; $wrap = new CS_REST_Campaigns('Campaign ID to Send', 'Your API Key'); $result = $wrap->send(array('ConfirmationEmail' => 'Confirmation Email Address', 'SendDate' => 'Date to send (yyyy-mm-dd or immediately)')); echo "Result of POST /api/v3/campaigns/{id}/send\n<br />"; if ($result->was_successful()) { echo "Scheduled with code\n<br />" . $result->http_status_code; } else { echo 'Failed with code ' . $result->http_status_code . "\n<br /><pre>"; var_dump($result->response); echo '</pre>'; }
<?php require_once '../../csrest_campaigns.php'; $wrap = new CS_REST_Campaigns('Campaign ID to get unsubscribes for', 'Your API Key'); $result = $wrap->get_unsubscribes('Get unsubscribes since', 1, 50, 'email', 'asc'); //$result = $wrap->get_unsubscribes(date('Y-m-d', strtotime('-30 days')), page, page size, order field, order direction); echo "Result of GET /api/v3/campaigns/{id}/unsubscribes\n<br />"; if ($result->was_successful()) { echo "Got unsubscribes\n<br /><pre>"; var_dump($result->response); } else { echo 'Failed with code ' . $result->http_status_code . "\n<br /><pre>"; var_dump($result->response); } echo '</pre>';
<?php require_once '../../csrest_campaigns.php'; $wrap = new CS_REST_Campaigns('Campaign ID to get bounces for', 'Your API Key'); $result = $wrap->get_bounces(1, 50, 'email', 'asc'); //$result = $wrap->get_bounces(page, page size, order field, order direction); echo "Result of GET /api/v3/campaigns/{id}/bounces\n<br />"; if ($result->was_successful()) { echo "Got bounces\n<br /><pre>"; var_dump($result->response); } else { echo 'Failed with code ' . $result->http_status_code . "\n<br /><pre>"; var_dump($result->response); } echo '</pre>';
<?php require_once '../../csrest_campaigns.php'; $wrap = new CS_REST_Campaigns('Campaign ID to Delete', 'Your API Key'); $result = $wrap->delete(); echo "Result of DELETE /api/v3/campaigns/{id}\n<br />"; if ($result->was_successful()) { echo "Deleted with code\n<br />" . $result->http_status_code; } else { echo 'Failed with code ' . $result->http_status_code . "\n<br /><pre>"; var_dump($result->response); echo '</pre>'; }
<?php require_once '../../csrest_campaigns.php'; $auth = array('access_token' => 'your access token', 'refresh_token' => 'your refresh token'); $wrap = new CS_REST_Campaigns('Campaign ID to get clicks for', $auth); $result = $wrap->get_clicks('Get clicks since', 1, 50, 'email', 'asc'); //$result = $wrap->get_clicks(date('Y-m-d', strtotime('-30 days')), page, page size, order field, order direction); echo "Result of GET /api/v3.1/campaigns/{id}/clicks\n<br />"; if ($result->was_successful()) { echo "Got clicks\n<br /><pre>"; var_dump($result->response); } else { echo 'Failed with code ' . $result->http_status_code . "\n<br /><pre>"; var_dump($result->response); } echo '</pre>';
<?php require_once '../../csrest_campaigns.php'; $wrap = new CS_REST_Campaigns('Campaign ID to get opens for', 'Your API Key'); $result = $wrap->get_opens('Get opens since', 1, 50, 'email', 'asc'); //$result = $wrap->get_opens(date('Y-m-d', strtotime('-30 days')), page, page size, order field, order direction); echo "Result of GET /api/v3/campaigns/{id}/opens\n<br />"; if ($result->was_successful()) { echo "Got opens\n<br /><pre>"; var_dump($result->response); } else { echo 'Failed with code ' . $result->http_status_code . "\n<br /><pre>"; var_dump($result->response); } echo '</pre>';
<?php require_once '../../csrest_campaigns.php'; $auth = array('access_token' => 'your access token', 'refresh_token' => 'your refresh token'); $wrap = new CS_REST_Campaigns('Campaign ID to get spam complaints for', $auth); $result = $wrap->get_spam('Get spam complaints since', 1, 50, 'email', 'asc'); //$result = $wrap->get_spam(date('Y-m-d', strtotime('-30 days')), page, page size, order field, order direction); echo "Result of GET /api/v3.1/campaigns/{id}/spam\n<br />"; if ($result->was_successful()) { echo "Got spam complaints\n<br /><pre>"; var_dump($result->response); } else { echo 'Failed with code ' . $result->http_status_code . "\n<br /><pre>"; var_dump($result->response); } echo '</pre>';
<?php require_once '../../csrest_campaigns.php'; $wrap = new CS_REST_Campaigns(NULL, 'Your API Key'); $template_content = array('Singlelines' => array(array('Content' => 'This is a heading', 'Href' => 'http://example.com/')), 'Multilines' => array(array('Content' => '<p>This is example</p><p>multiline <a href=\\"http://example.com\\">content</a>...</p>')), 'Images' => array(array('Content' => 'http://example.com/image.png', 'Alt' => 'This is alt text for an image', 'Href' => 'http://example.com/')), 'Repeaters' => array(array('Items' => array(array('Layout' => 'My layout', 'Singlelines' => array(array('Content' => 'This is a repeater heading', 'Href' => 'http://example.com/')), 'Multilines' => array(array('Content' => '<p>This is example</p><p>multiline <a href=\\"http://example.com\\">content</a>...</p>')), 'Images' => array(array('Content' => 'http://example.com/image.png', 'Alt' => 'This is alt text for a repeater image', 'Href' => 'http://example.com/'))))))); # $template_content as defined above would be used to fill the content of # a template with markup similar to the following: # # <html> # <head><title>My Template</title></head> # <body> # <p><singleline>Enter heading...</singleline></p> # <div><multiline>Enter description...</multiline></div> # <img id="header-image" editable="true" width="500" /> # <repeater> # <layout label="My layout"> # <div class="repeater-item"> # <p><singleline></singleline></p> # <div><multiline></multiline></div> # <img editable="true" width="500" /> # </div> # </layout> # </repeater> # <p><unsubscribe>Unsubscribe</unsubscribe></p> # </body> # </html> $result = $wrap->create_from_template('Campaigns Client ID', array('Subject' => 'Campaign Subject', 'Name' => 'Campaign Name', 'FromName' => 'Campaign From Name', 'FromEmail' => 'Campaign From Email Address', 'ReplyTo' => 'Campaign Reply To Email Address', 'ListIDs' => array('First List', 'Second List'), 'SegmentIDs' => array('First Segment', 'Second Segment'), 'TemplateID' => 'Template ID', 'TemplateContent' => $template_content)); echo "Result of POST /api/v3/campaigns/{clientID}/fromtemplate\n<br />"; if ($result->was_successful()) { echo "Created with ID\n<br />" . $result->response; } else {
<?php require_once '../../csrest_campaigns.php'; $wrap = new CS_REST_Campaigns('Campaign ID to Test', 'Your API Key'); $result = $wrap->send_preview(array('*****@*****.**', '*****@*****.**'), 'Fallback'); echo "Result of POST /api/v3/campaigns/{id}/sendpreview\n<br />"; if ($result->was_successful()) { echo "Preview sent with code\n<br />" . $result->http_status_code; } else { echo 'Failed with code ' . $result->http_status_code . "\n<br /><pre>"; var_dump($result->response); echo '</pre>'; }
<?php require_once '../../csrest_campaigns.php'; $wrap = new CS_REST_Campaigns('Campaign ID to get the summary of', 'Your API Key'); $result = $wrap->get_summary(); echo "Result of GET /api/v3/campaigns/{id}/summary\n<br />"; if ($result->was_successful()) { echo "Got summary\n<br /><pre>"; var_dump($result->response); } else { echo 'Failed with code ' . $result->http_status_code . "\n<br /><pre>"; var_dump($result->response); } echo '</pre>';
<?php require_once '../../csrest_campaigns.php'; $auth = array('access_token' => 'your access token', 'refresh_token' => 'your refresh token'); $wrap = new CS_REST_Campaigns('Campaign ID to get the email client usage for', $auth); $result = $wrap->get_email_client_usage(); echo "Result of GET /api/v3.1/campaigns/{id}/emailclientusage\n<br />"; if ($result->was_successful()) { echo "Got email client usage\n<br /><pre>"; var_dump($result->response); } else { echo 'Failed with code ' . $result->http_status_code . "\n<br /><pre>"; var_dump($result->response); } echo '</pre>';
function removeCampaign($campaignID) { $this->loadWrapperClass('csrest_campaigns'); $wrap = new CS_REST_Campaigns($campaignID, $this->_api_key); return $wrap->delete(); }