Open digitalpianism opened 2 years ago
Code examples:
#return a list of all email templates in your account
$client->templates->getAllTemplates();
#create a new email template
$client->templates->createNewTemplate('Template Name', 'Template HTML');
#update an email template
$client->templates->updateTemplate('Template ID', 'New Template Name', 'New Template HTML');
#delete an email template
$client->templates->deleteTemplate('Template ID');
#clone a template
$client->templates->cloneTemplate('Template ID', 'Cloned Template Name');
#render a template
#context is a string e.g. { "name" : "George Washington", "state" : "VA" }
$client->templates->renderTemplate('Template ID', 'Template Context');
#render and send a template
#recipients details can be string, or JSON encoded array of objects with "email" and "name" keys.
#e.g. abraham.lincoln@klaviyo.com OR [{"name":"Abraham Lincoln","email":"abraham.lincoln@klaviyo.com"}]
$client->templates->sendTemplate('Template ID', 'From Email', 'From Name', 'Email Subject', 'Recipient Details', 'Template Context');
I had the need to use the PHP SDK to do API to the Templates endpoint: https://apidocs.klaviyo.com/reference/templates
As this wasn't supported, I wrote the library class.