1. Go to this page and download the library: Download zaycon/whatcounts library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zaycon / whatcounts example snippets
$whatcounts = new ZayconWhatCounts\WhatCounts( [YOUR_API_REALM], [YOUR_API_PASSWORD] );
$article = new ZayconWhatCounts\Article();
$article
->setName('blank-test');
$whatcounts->createBlankArticle($article);
$article = new ZayconWhatCounts\Article();
$article
->setName('test')
->setTitle('Test Article Title')
->setDescription('Test Article Description')
->setDeck('This is the actual article deck.')
->setCallout('Test Article Callout')
->setBody('Test Article Body')
->setAuthorName('Joe Smith')
->setAuthorBio('This is the bio for Joe Smith')
->setAuthorEmail('[email protected]')
->setFolderId(0);
$whatcounts->createArticle($article);
$article = new ZayconWhatCounts\Article();
$article
->setId(5)
->setName('article-1')
->setTitle('Test Article Title')
->setDescription('Test Article Description')
->setDeck('This is the actual article deck.')
->setCallout('Test Article Callout')
->setBody('Test Article Body')
->setAuthorName('Joe Smith')
->setAuthorBio('This is the bio for Joe Smith')
->setAuthorEmail('[email protected]')
->setFolderId(0);
$is_updated = $whatcounts->updateArticle($article);
$message = new \ZayconWhatCounts\Mail();
$message
->setListId(10);
->setFromAddress('[email protected]');
->setReplyToAddress('[email protected]');
->setBounceAddress('[email protected]');
->setSenderAddress(NULL);
->setSendToAddress('[email protected]');
->setCcToAddress('[email protected]');
->setTemplateId(3);
->setBodyText('This is plain text.'); // This is usually defined in the template.
->setBodyHtml('<h2>This is a test</h2>'); // This is usually defined in the template.
->setSubject('Test from API'); // This is usually defined in the template.
->setFormat(99);
->setCampaignName(NULL);
->setVirtualMta(NULL);
->setDuplicate(FALSE);
->setIgnoreOptout(TRUE); // Set to TRUE if sending a transactional email, which ignores any opt out.
->setCharacterEncoding(NULL); // This is usually defined in the template.
->setData('customLastname,customSalutation^Smith,Mr');
$output = $whatcounts->sendOneOffMessage($message);
$message = new \ZayconWhatCounts\Mail();
$message
->setListId(10);
->setFromAddress('[email protected]');
->setReplyToAddress('[email protected]');
->setBounceAddress('[email protected]');
->setSenderAddress(NULL);
->setSendToAddress('[email protected]');
->setCcToAddress('[email protected]');
->setTemplateId(3);
->setBodyText('This is plain text.'); // This is usually defined in the template.
->setBodyHtml('<h2>This is a test</h2>'); // This is usually defined in the template.
->setSubject('Test from API'); // This is usually defined in the template.
->setFormat(99);
->setCampaignName(NULL);
->setVirtualMta(NULL);
->setDuplicate(FALSE);
->setIgnoreOptout(TRUE); // Set to TRUE if sending a transactional email, which ignores any opt out.
->setCharacterEncoding(NULL); // This is usually defined in the template.
->setData('customLastname,customSalutation^Smith,Mr');
$output = $whatcounts->subscribeAndSendOneOffMessage($message);
$template = new ZayconWhatCounts\Template;
$template
->setFolderId(0)
->setName("Another Test Template")
->setSubject("Another Test from WhatCounts")
->setBodyPlain("Hello %%set salutation = \$customSalutation%%%%\$salutation%% %%set last_name = \$customLastname%%%%\$last_name%%!")
->setBodyHtml("<html><head><title></title></head><body><h2>Hello %%set salutation = \$customSalutation%%%%\$salutation%% %%set last_name = \$customLastname%%%%\$last_name%%!</h2></body></html>")
->setDescription("This is the description");
$whatcounts->createTemplate($template);
$template = new ZayconWhatCounts\Template;
$template
->setTemplateId(35)
->setFolderId(0)
->setName("Another Test Template")
->setSubject("Another Test from WhatCounts (updated)")
->setBodyPlain("(updated) Hello %%set salutation = \$customSalutation%%%%\$salutation%% %%set last_name = \$customLastname%%%%\$last_name%%!")
->setBodyHtml("<html><head><title></title></head><body><h2>(updated) Hello %%set salutation = \$customSalutation%%%%\$salutation%% %%set last_name = \$customLastname%%%%\$last_name%%!</h2></body></html>")
->setDescription("This is the description (updated)");
$output = $whatcounts->updateTemplate($template);
define('TEMPLATE_TYPE_PLAIN', 1);
define('TEMPLATE_TYPE_HTML', 2);
$template = new ZayconWhatCounts\Template;
$template
->setName("Another Test Template");
$output = $whatcounts->previewTemplate($template, TEMPLATE_TYPE_HTML);
$output = $whatcounts->showSegmentationRules();
$segmentation_rule = new ZayconWhatCounts\SegmentationRule();
$segmentation_rule->setListId(14);
$segmentation_rule->setName('Test Segmentation Rule');
$segmentation_rule->setDescription('This is a test segmentation rule.');
$segmentation_rule->setType('adv');
$segmentation_rule->setRules("email='[email protected]'");
$output = $whatcounts->createSegmentationRule($segmentation_rule);
$segmentation_rule = new ZayconWhatCounts\SegmentationRule();
$segmentation_rule->setId(7);
$segmentation_rule->setListId(14);
$segmentation_rule->setName('Test Segmentation Rule (updated)');
$segmentation_rule->setDescription('This is a test segmentation rule.');
$segmentation_rule->setType('adv');
$segmentation_rule->setRules("email='[email protected]'");
$output = $whatcounts->updateSegmentationRule($segmentation_rule);
$segmentation_rule = new ZayconWhatCounts\SegmentationRule();
$segmentation_rule->setId(7);
$output = $whatcounts->deleteSegmentationRule($segmentation_rule);
$segmentation_rule = new ZayconWhatCounts\SegmentationRule();
$segmentation_rule->setId(8);
$segmentation_rule->setListId(14);
$output = $whatcounts->testSegmentationRule($segmentation_rule);
$social_provider = new ZayconWhatCounts\SocialProvider();
$social_provider->setProviderId(522);
$whatcounts->getSocialProviderById($social_provider);
$social_provider = new ZayconWhatCounts\SocialProvider();
$social_provider
->setUsername('[email protected]')
->setProviderName('facebook');
$whatcounts->getSocialProviderByUserName($social_provider);
$social_provider = new ZayconWhatCounts\SocialProvider();
$social_provider->setProviderId(522);
$is_deleted = $whatcounts->deleteSocialProviderById($social_provider);
$template = new ZayconWhatCounts\Template(); $template->setTemplateId(14);
$social_provider = new ZayconWhatCounts\SocialProvider();
$social_provider->setProviderName('twitter');
$social_post = new ZayconWhatCounts\SocialPost();
$social_post->setPost('This is a post created from the API.');
$output = $whatcounts->setSocialPostForTemplate($template, $social_provider, $social_post);
$template = new ZayconWhatCounts\Template();
$template->setTemplateId(14);
$output = $whatcounts->getSocialPostsByTemplateId($template);
$template = new ZayconWhatCounts\Template();
$template->setName('Test Template');
$output = $whatcounts->getSocialPostsByTemplateName($template);