Salesforce

Getting Started with the Fotomoto API

« Go Back

Information

 
Body

The Fotomoto API

We offer two APIs for different purposes: the Public API and the Affiliate API.

The Public API gives developers a way to create their own Buy links, control how and what page of the Fotomoto shopping cart Widget is opened, manually load (or "check in") images to the Fotomoto Dashboard, and several other abilities including passing in the URL of the accompanying high resolution image that is needed to create prints and other products.

The Affiliate API gives multi-site service owners the ability to create new Fotomoto accounts for their users via POST instead of requiring users to go through the usual Fotomoto account registration process. Users signed up via this process receive an email with instructions on how to finalize their account registration as explained in How to register a Fotomoto account created via the Fotomoto Partner Program.

Public API

Getting started

  1. Get the Fotomoto Script: if you have a Fotomoto account, go to the Settings page and click the "Get Script" button, then copy the Script. If you don't have an account, create one on our Signup Page then follow the prompts and copy the Fotomoto Script on the final step.
  2. Enable API Mode: Paste the copied Script in to a text editor, and append the ?api=true parameter to the Fotomoto Script so you can use Public API functions in your site code.
  3. Install the Fotomoto Script to your template or page
    <!-- The contents of your page are here -->
    
    <!-- Fotomoto Script -->
    <script type="text/javascript" src="//widget.fotomoto.com/stores/script/443665d5b1450ca39e9c84741ab5d8732de5XXXX.js?api=true"></script>
    
    <!-- Closing body tag -->
    </body>


API reference documents

Example - putting a custom Buy Button under a photo

  1. Choose how you will reference your image: either use the image URL or give the image a unique ID like id='mainPhoto' as shown in the example below.
  2. Select the desired function. In this case we will make our own Buy button, which calls a function to open the Widget. We will use FOTOMOTO.API.showWindow() from our Fotomoto API Function reference page.
  3. Add parameters to the function to tell the Widget which image to open on which page of the Widget. In this case we will use FOTOMOTO.API.PRINT to open the Buy Print page in the Widget.
  4. Assign the function to an action. Here we add onclick to our button:
    <!-- Your image with ID mainPhoto -->
    <img id="mainPhoto" alt="My sample image" src="https://www.example.com/image_directory/your-image.jpg">
    
    <!-- A custom Buy Button with showPrint function onclick -->
    <button type="button" onclick="showPrint();">Show Print</button>
    
    <!-- Function to open the Fotomoto shopping cart Widget -->
    <script>
        function showPrint() {
            FOTOMOTO.API.showWindow(FOTOMOTO.API.PRINT, "mainPhoto");
        }
    </script>

Example - Using the getStoreID method

The Fotomoto Script must be included on every page where images will be for sale, and for Fotomoto to work, the right Store ID must be used in the Script. You can generate the correct Store ID for the site using the getStoreID method. The Store ID will go in the Script as shown here:  

<script type="text/javascript" src="//widget.fotomoto.com/stores/script/<uniqueStoreID>.js"></script>

The getStoreID method takes two parameters: the first is the domain of your website, for this example "http://localhost:8092". The second is a string, which is the name of callback function that returns the Store ID, for example:

FOTOMOTO.API.getStoreID("http://localhost:8092", "callbackFunction");

 

Affiliate API

Getting started

You will need a Fotomoto affiliate account to use the Affiliate API. To request one, please send your request to support@fotomoto.com.

Creating a new Fotomoto user account

To create an account, you will post the following information about the new user:

  • api_key: Found on the API/Affiliate Keys page of your affiliate account
  • affiliate_key: Found on the API/Affililate Keys page of your affiliate account
  • first_name: The first name of the user
  • last_name: The last name of the user
  • email: The email address for the Fotomoto account. The activation email is sent to this address. Note the email address must be unique and not already registered in Fotomoto.
  • domain: The domain of the new users website. Note the domain must be unique and not already registered in Fotomoto
  • alternate_sites: an optional comma-separated list of alternative domains of other URLs that the user can sell images from via the same Fotomoto account.

Once a new account is created, it is associated with your Affiliate account, and the user will receive an email with instructions on how to activate their account as explained in How to register a Fotomoto account created via the Fotomoto Partner Program.

Here is the code to register a user and receive a JSON response; post to https://affiliate.fotomoto.com/osignup.json:

<form action="https://affiliate.fotomoto.com/osignup.json" method="post" target="result" accept-charset="UTF-8">

<label for="api_key">API key:</label>
<input id="api_key" name="api_key" type="text" value=""/><br/>

<label for="affiliate_key">Affiliate Key:</label>
<input id="affiliate_key" name="affiliate_key" type="text" value=""/><br/>

<label for="first_name">First Name:</label>
<input id="first_name" name="first_name" size="30" type="text" value="" /><br/>

<label for="last_name">Last Name:</label>
<input id="last_name" name="last_name" size="30" type="text" value="" /><br/>

<label for="email">Email:</label>
<input id="email" name="email" size="30" type="email" value="" /><br/>

<label for="domain">Domain:</label>
<input id="domain" name="domain" size="30" type="text" value="" /><br/>

<label for="alternate_sites">Alternate site addresses<br> (comma separated):</label>
<textarea rows="8" name="alternate_sites" id="alternate_sites" cols="40"></textarea><br/>

<button type="submit" id="submit" name="sub">Submit</button>

</form>

<p>Result:</p>
     <iframe id="result" name="result" style="border-style: none; width: 100%; height: 300px;"></iframe>

Here is the code to register a user and receive an XML response; post to https://affiliate.fotomoto.com/osignup.xml:

<form action="https://affiliate.fotomoto.com/osignup.xml" method="post" target="result" accept-charset="UTF-8">

<label for="api_key">API key:</label>
<input id="api_key" name="api_key" type="text" value=""/><br/>

<label for="affiliate_key">Affiliate Key:</label>
<input id="affiliate_key" name="affiliate_key" type="text" value=""/><br/>

<label for="first_name">First Name:</label>
<input id="first_name" name="first_name" size="30" type="text" value="" /><br/>

<label for="last_name">Last Name:</label>
<input id="last_name" name="last_name" size="30" type="text" value="" /><br/>

<label for="email">Email:</label>
<input id="email" name="email" size="30" type="email" value="" /><br/>

<label for="domain">Domain:</label>
<input id="domain" name="domain" size="30" type="text" value="" /><br/>

<label for="alternate_sites">Alternate site addresses<br> (comma separated):</label>
<textarea rows="8" name="alternate_sites" id="alternate_sites" cols="40"></textarea><br/>

<button type="submit" id="submit" name="sub">Submit</button>

</form>

<p>Result:</p>
     <iframe id="result" name="result" style="border-style: none; width: 100%; height: 300px;"></iframe>

Adding the Fotomoto Script to a user page

The Fotomoto Partner Program gives Affiliates a way to track sales made by their Member stores. To achieve this, the Affiliate Key must be added to the Fotomoto Script as below.
  1. Get the Fotomoto Script: build the Fotomoto Script as in the example above and copy it.
  2. Pass in your Affiliate Key: Paste the copied Script in to a text editor, and append the &aid= parameter as below, replacing the XXXXXXXXX with your Affiliate Key from the API/Affiliate Keys page of your Affiliate Dashboard. This will associate any sales from the page with your Affiliate account.
  3. Install the Fotomoto Script to your template or page
    <!-- The contents of your page are here -->
    
    <!-- Fotomoto Script -->
    <script type="text/javascript" src="//widget.fotomoto.com/stores/script/443665d5b1450ca39e9c84741ab5d8732de5XXXX.js?aid=XXXXXXXXX"></script>
    
    <!-- Closing body tag -->
    </body>

API support

If you have any questions about using the Fotomoto API, contact Fotomoto Support.

TitleGetting Started with the Fotomoto API
URL Name8316-getting-started-with-the-fotomoto-api


Powered by