The Fulfillment API is used for authorizing eBook decryption and downloads for your users through the web.

By creating a digitally signed download link, using your secret key and other account credentials, you can call the Fulfillment API to authorize immediate and secure downloads. Please examine the code samples below to get an understanding on how the digitally signed download link is generated.

PHP

<!DOCTYPE html> 
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <?php
        $dateval=time();
        $sharedSecret = ""; // Place your unique distributor shared secret, keep this safe or the api can be used in your stead by others!
        $transactionId = ""; // Must be a unique value, generated by you for your records
        $resourceId = ""; // Place Content Server Resource ID starting with urn:uuid:
        $linkURL = "http://acs4.editionguard.com/fulfillment/URLLink.acsm"; // Content server service url, do not change.
        $orderSource = ""; // Your EditionGuard subscription e-mail address.
        // Create download URL
        $URL = "action=enterorder&ordersource=".urlencode($orderSource)."&orderid=".urlencode($transactionId)."&resid=".urlencode("$resourceId")."&dateval=".urlencode($dateval)."&gblver=4";
        /* If you want the eBook to expire after a certain period of time,
        append the "rights" parameter to the link as shown below.
        If not, simply omit this parameter.
        The time period for the below example is three days.
        We convert it into seconds using the formula:
        3 days x 24 hours x 60 minutes x 60 seconds */
        $URL .= "&rights=$".urlencode("urt#").(3 * 24 * 60 * 60)."$";
        // Digitaly sign the request
        $URL = $linkURL."?".$URL."&auth=".hash_hmac("sha1", $URL, base64_decode($sharedSecret));
        ?>
        <a href="<?php print $URL; ?>"> Click here to download eBook</a>
    </body>
</html>

ASP.NET C#

<%@ Page Language="C#" %> 
<%@ Import Namespace="System.Security.Cryptography"  %>
<%@ Import Namespace="System.Globalization" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    public static string SignedEbookLink()
    {
        string sharedSecret = ""; // Place your unique distributor shared secret, keep this safe or the api can be used in your stead by others!
        string transactionId = ""; // Must be a unique value, generated by you for your records
        string resourceId = ""; // Place Content Server Resource ID starting with urn:uuid:
        string orderSource = ""; // Your EditionGuard subscription e-mail address.
        string querystring = string.Format("action=enterorder&ordersource={0}&orderid={1}&resid={2}&gbauthdate={3}&dateval={4}&gblver=4", HttpUtility.UrlEncode(orderSource), transactionId, HttpUtility.UrlEncode(resourceId), HttpUtility.UrlEncode(DateTime.Now.ToUniversalTime().ToString("MM/dd/yyyy HH:mm", DateTimeFormatInfo.InvariantInfo)), ToUnixTime(DateTime.Now));
        /* If you want the eBook to expire after a certain period of time,
        append the "rights" parameter to the link as shown below.
        If not, simply omit this parameter.
        The time period for the below example is three days.
        We convert it into seconds using the formula:
        3 days x 24 hours x 60 minutes x 60 seconds */
        querystring += "&rights=$" + HttpUtility.UrlEncode("urt#") + (3 * 24 * 60 * 60) + "$";
        return string.Format("http://acs4.editionguard.com/fulfillment/URLLink.acsm?{0}&auth={1}", querystring, HashingHmacSha1(querystring, sharedSecret));
    }
    private static string HashingHmacSha1(string value, string key)
    {
        byte[] sharedSecretBytes = Convert.FromBase64String(key);
        ASCIIEncoding encoding = new ASCIIEncoding();
        HMACSHA1 hmacsha1 = new HMACSHA1(sharedSecretBytes);
        byte[] messageBytes = encoding.GetBytes(value);
        byte[] hashmessage = hmacsha1.ComputeHash(messageBytes);
        return ByteToString(hashmessage);
    }
    private static string ByteToString(byte[] buff)
    {
        string sbinary = "";
        for (int i = 0; i < buff.Length; i++)
        {
            sbinary += buff[i].ToString("X2");
        }
        return (sbinary.ToLower());
    }
    static int ToUnixTime(DateTime timeToConvert)
    {
        TimeSpan span = new TimeSpan(DateTime.Parse("1/1/1970").Ticks);
        DateTime time = timeToConvert.Subtract(span);
        int t = (int)(time.Ticks / 10000000);
        return (t);
    }
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title> </title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <a href="<% =SignedEbookLink() %> "> Click here to download eBook</a>
    </div>
    </form>
</body>
</html>

Ruby( this works for a command line example)

1 require 'uri'

2 require 'openssl'

3 require "base64"

4 dateval=Time.now.to_i;

5 sharedSecret = "WBpayMx+Yy4NJ16NBYKMp+sggoI=";

6 transactionId = "someuniquevaluehere";

7 resourceId = "urn:uuid:75fa9994-4354-437d-b564-

8 eac7dd8018d4";

9 linkURL = 

10"http://acs4.editionguard.com/fulfillment/URLLink.acsm";

11 orderSource = "you@youremail.com";

12 PARMS = "action=enterorder&ordersource=" + URI::escape(orderSource.to_s) + "&orderid=" +  

13 URI::escape(transactionId.to_s) + "&resid=" +  URI::escape(resourceId.to_s) + "&dateval=" +  

14  URI::escape(dateval.to_s) + "&gblver=4"

15 - URL = linkURL + "?" + PARMS + "&auth=" + OpenSSL::HMAC.hexdigest('sha1', Base64.decode64(sharedSecret),PARMS)

puts URL












Did this answer your question?