ContentsIntroductionThe Template Hosting service is used to transfer and store plain text and html email content on the ePriority servers. The Template Hosting web service allows transfer of content to and from ePriority, updating existing hosted content, version control, content statuses indicating production worthy or currently editable drafts, and metadata. Errors may occur when bad credentials are supplied or incorrect/incomplete data is given in the template query. If you have not already done so, you should read the «ePriority Service Overview» before going further with this document as it will provide context for all ePriority features. HTTP QueryTo interact with a hosted template through an HTTPS query, the following parameters must be supplied: AuthenticationThe cid (ePriority Client ID), authDate and authHash parameters are required for authentication of all Web API requests. See authentication instructions. Using the Template ServiceSample Requests
https://www.epriority.com/TemplateService?cid=12345&version=1&authDate=2010-04-19T08:24:39&authHash=3ad64d6780d2c4762b335570646939e0&action=list
https://www.epriority.com/TemplateService?cid=12345&authDate=1303224086377&authHash=cce48ea23edf7c97fa65bb1f2bd1b341&action=create&user=toddplankton&name=Account_Update&desc=Account update alert&comment=Initial Revision&type=text/html&contents=Dear User, Your account has been updated. Your company, The Company
https://www.epriority.com/TemplateService?cid=12345&authDate=1303225511226&authHash=7f6038f801fb69cd9513a7a7d9a31482&action=update&user=toddplankton&name=Account_Update&desc=Account
update alert&comment=Initial Revision&type=text/html&contents=Dear User, Your account has
been updated. Your company, The Company
https://www.epriority.com/TemplateService?cid=12345&authDate=1303224194210&authHash=381a47e16fb5d9f20ec99a556e3cdf68&action=view&name=Account_Update&version=v3
https://www.epriority.com/TemplateService?cid=12345&authDate=1303240706669&authHash=31701e5db9800e11619764aec833cba1&action=release&name=Account_Update&user=vernonshofts
https://www.epriority.com/TemplateService?cid=12345&authDate=1303240706669&authHash=31701e5db9800e11619764aec833cba1&action=delete&name=Account_Update&user=vernonshofts
https://www.epriority.com/TemplateService?cid=12345&authDate=1303240706669&authHash=31701e5db9800e11619764aec833cba1&action=preview&name=Account_Update&version=production
Outputs
HTTP response 403 (forbidden) is returned when authentication fails. Successful List Request<?xml version="1.0" encoding="iso-8859-1"?> <root> <template> <template_id>52<template_id> <client_id>1105<client_id> <name>ARCHER_LETTER<name> <description>my transactional stuff<description> <comment>won't sell an apple<comment> <status>0<status> <version>1<version> <content_type>text/html<content_type> <charset>iso-8859-1<charset> <creator>tteague@dstoutput.com<creator> <last_editor /> <releasor /> <deletor /> <byte_count>29<byte_count> <parse>false<parse> <creation_dt>2011-09-12<creation_dt> <last_mod_dt>2011-09-12<last_mod_dt> </template> <template> <template_id>28<template_id> <client_id>1105<client_id> <name>ARCHER_NEWSLETTER<name> <description>Awesome newsletter that everyone wants<description> <comment>Initial Revision<comment> <status>2<status> <version>1<version> <content_type>text/html<content_type> <charset>iso-8859-1<charset> <creator>tteague@dstoutput.com<creator> <last_editor>tteague@dstoutput.com<last_editor> <releasor>tteague@dstoutput.com<releasor> <deletor /> <byte_count>2009<byte_count> <parse>false<parse> <creation_dt>2011-08-03<creation_dt> <last_mod_dt>2011-08-05<last_mod_dt> </template> </root> Successful List/Create/Update/Release/Delete Request<?xml version="1.0" encoding="UTF-8"?> <root> <status>SUCCESS</status> </root> Successful Preview RequestText/plain or HTML content of body with a text/plain or html mimetype accordingly. Successful View Request<xml version="1.0" encoding="iso-8859-1"?> <root> <template> <template_id>28<template_id> <client_id>1105<client_id> <name>ARCHER_NEWSLETTER<name> <description>Awesome newsletter that everyone wants<description> <comment>Initial Revision<comment> <status>2<status> <version>3<version> <content_type>text/html<content_type> <charset>iso-8859-1<charset> <creator>tteague@dstoutput.com<creator> <last_editor>tteague@dstoutput.com<last_editor> <releasor>tteague@dstoutput.com<releasor> <deletor /> <byte_count>2107<byte_count> <parse>false<parse> <creation_dt>2011-08-03<creation_dt> <last_mod_dt>2011-08-05<last_mod_dt> <content> <CDATA[ <html> <head> <style type="text/css"> #madeup { } #mainbody { border: 1px solid black; background-color: white; padding: 5%; margin: 5%; min-width: 400px; background-image: url( "companyInc.png" ); background-repeat: no-repeat; background-position: right center; } #header { border-bottom: 1px solid #2F8395; text-align: right; } #imagediv { position: absolute; left: 250px; top: 200px; opacity:0.2; filter:alpha(opacity=20); } #business { font-size: x-small; } a { color: brown; } </style> </head> <body bgcolor="green"> <div id="mainbody"> <div id="header"> <img src="toplogo.gif" border="0"/> <div> <p>Dear <EPRIORITY key="First" name="PDATA" /> <epriority name="Pdata" key="last"/>lt;p> <p>Your Company, Inc. bill is due. Please visit the Company, Inc. website to submit payment, in the amount of $74.33.<p> <p>This message was delivered to the following ISP:<epriority name="Pdata" key="ISP"/>lt;p> <p>Wanda Support<br/> <a href="<epriority name="TrackLink" url="www.msn.com" />Visit MSN<a>lt;br/>lt;br/> ePriority Development Group<br/> DST Output, Inc.<br/> customerservice@dstoutput.com<p> <a href="<epriority name="TrackLink" url="http://www.google.com"/>Company, Inc. Support<a>lt;br/>lt;br/> <div id="business"> You have received this email because you have signed up for billing notifications. If you would like to cancel these notifications, <a href="<epriority name="OptOut" />opt-out<a> To subscribe to billing notification emails in the future, contact a Company, Inc. representative or <a href="<epriority name="OptIn" />opt-in<a> <epriority name="TrackViewing" /> <div> <div> <body> <html> ]]<content> <template> <root> Unsuccessful Request<?xml version="1.0" encoding="ISO-8859-1"?> <root> <status>FAILED</status> <message>Error message</message> </root> Unsuccessful Request (Invalid parameter)<root> <status>FAILED</status> <message>Parameter invalid</message> <root> Java Exampleimport java.io.*; import java.net.*; import java.text.*; import java.util.*; import java.security.MessageDigest; import javax.net.ssl.*; public class EpriorityTemplateService { static int myAccountId = 12345; public static void main (String[] args) { try { // Prepare Authentication Credentials SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); sdf.setTimeZone(TimeZone.getTimeZone("Universal")); String authDate = sdf.format(new Date()); String webServicePw = args[0]; String searchAddress = args[1]; String digestString = authDate + webServicePw; MessageDigest md = MessageDigest.getInstance("SHA256"); byte[] hash = md.digest( digestString.getBytes() ); String hashHex = asHex( hash ); // Prepare Content StringBuilder content = new StringBuilder(); content.append("cid="); content.append(myAccountId); content.append("&authDate="); content.append(authDate); content.append("&authHash="); content.append(hashHex); content.append("&action=list"); // Connect to URL URL url = new URL ("https://www.epriority.com/TemplateService"); URLConnection urlConn = url.openConnection(); urlConn.setDoInput(true); urlConn.setDoOutput(true); urlConn.setUseCaches(false); urlConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); // Send HTTP POST DataOutputStream printout = new DataOutputStream(urlConn.getOutputStream()); printout.writeBytes (content.toString()); printout.flush (); printout.close (); // Read XML Response BufferedReader input = new BufferedReader(new InputStreamReader(urlConn.getInputStream())); String str; while (null != ((str = input.readLine()))) { System.out.println(str); } input.close (); } catch (Exception e) { System.out.println(e.getMessage()); } } public static final String asHex(byte[] data) { //double size, two bytes (hex range) for one byte StringBuffer buf = new StringBuffer(data.length * 2); for (int i = 0; i < data.length; i++) { //don't forget the second hex digit if (((int) data[i] & 0xff) < 0x10) { buf.append("0"); } buf.append(Long.toString((int) data[i] & 0xff, 16)); } return buf.toString(); } } |