SEOshop Documentation

Installing an app

When you are building an application for multiple stores, you need to implement an installation script for storing the store identifier (ID), API token and store language for later use. You will also receive a signature in the GET parameters for validating the request before storing the store information. After storing the store information you can make a connection with the Webshopapp API per store and do what you need to do. You can set the URL to your installation script in the partner environment (Under Apps > (Name app) > Success URL).

Clusters

The Lightspeed eCom platform has multiple clusters. In order to communicate with a specific cluster you need to identify on which cluster the shop is hosted. The success URL will contain a parameter that identifies on which cluster the shop is hosted; cluster_id. Currently these are the clusters that are in use: us1 and eu1.

Do not include the cluster_id in the signature.

PHP client example:

<?php
// Configure
// --------------------------------------------------
define('APP_KEY', 'YOUR_APP_KEY');
define('APP_SECRET', 'YOUR_APP_SECRET');


// On install
// --------------------------------------------------
if (isset($_GET['language'])
 && isset($_GET['shop_id'])
 && isset($_GET['signature'])
 && isset($_GET['timestamp'])
 && isset($_GET['token']))
{
    // Create the signature
    $params = array(
        'language' => $_GET['language'],
        'shop_id' => $_GET['shop_id'],
        'timestamp' => $_GET['timestamp'],
        'token' => $_GET['token'] // in between token
    );

    ksort($params);

    $signature = '';

    foreach ($params as $key => $value)
    {
        $signature .= $key.'='.$value;
    }

    $signature = md5($signature.APP_SECRET);

    // Validate the signature
    if ($signature == $_GET['signature'])
    {
        // Store the store identifier (ID), API token and store language for later use
        // Each API token represents a single store
        mysql_query("
         INSERT INTO shops (
         	shop_id, 
         	token, 
         	language, 
         	clusterId
         ) VALUES (
         	'".mysql_real_escape_string($_GET['shop_id'])."',
 			'".mysql_real_escape_string($_GET['token'])."',
 			'".mysql_real_escape_string($_GET['language'])."',
			'".mysql_real_escape_string($_GET['cluster_id'])."'
		 )");

        // Redirect the user to your app
        header('Location: http://www.yourdomain.com/');
        exit;
    }
}
// Making calls with the API
// --------------------------------------------------
$shopId = 1;

$result = mysql_query("SELECT * FROM shops WHERE shop = '".$shopId."'");

$shop = mysql_fetch_assoc($result);

// Create authentication token
$userSecret = md5($shop['token'].APP_SECRET);
 
// Connect to the Webshopapp API using the cluster, stored API token and store language   
$cluster = 'eu1' // Where cluster can be one of `eu1`, `us1` 
$api = new WebshopappApiClient($cluster, APP_KEY, $userSecret, $shop['language']);


// Todo: Do awesome stuff with the Webshopapp API
Was this article helpful? Yes No
One moment please
Thanks for your feedback.