Automate importing of templates for clients

Hi there,

Has anyone built any tools that you can use to bulk import templates?

I can see that this should be technically doable within the API, but I think this might be pushing my coding abilities a bit. When setting up clients, I'd like to be able to automate the import of a range of templates for clients to use while test driving the software. I can see artesanocode.com has a tool which can do this, but it also has a lot of other features that I dont need - I only need the template imports :)

Anyone have any code or tools they'd be willing to share? (I'll buy you something nice as a thanks!)

Thanks!

jamesd jamesd, 6 years ago

This functionality you've described is actually available out of the box with all the API client libraries/wrappers.

First, you'll want to host the template html file, assets zip file and optionally a screenshot somewhere, as these URLs are required as input when creating templates via the API.

You or your website developer will want to choose a client library/wrapper which suits your website setup (which you didn't describe above) and make the call to add a template as many times as you need to for all your templates.

Here is an example using the PHP client library:

<?php

require_once '../../csrest_templates.php';

$wrap = new CS_REST_Templates(NULL, 'Your API Key');

$result = $wrap->create('Templates Client ID', array(
    'Name' => 'Template Name',
    'HtmlPageURL' => 'Template HTML Url',
    'ZipFileURL' => 'Template Images Zip URL',
    'ScreenshotURL' => 'Template Screenshot URL'
));

echo "Result of POST /api/v3/templates/{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>';
}

200,000 companies around the world can't be wrong.

From Australia to Zimbabwe, and everywhere in between, companies count on 
Campaign Monitor for email campaigns that drive real business results.

Get started for free
1-888-533-8098