<?php require '../MerchiumClient.php'; //define('MERCHIUM_DEBUG', true); define('MERCHIUM_APP_KEY', '[YOUR_APP_KEY]'); define('MERCHIUM_CLIENT_SECRET', '[YOUR_CLIENT_SECRET]'); if (empty($_COOKIE['merchium_shop_domain']) || empty($_COOKIE['merchium_access_token'])) { echo "<p>Application not installed</p>"; exit; } $shop_domain = $_COOKIE['merchium_shop_domain']; $access_token = $_COOKIE['merchium_access_token']; $merchium = new MerchiumClient(MERCHIUM_APP_KEY, MERCHIUM_CLIENT_SECRET, $shop_domain, $access_token); ?> <!DOCTYPE html> <html> <head> <script src='http://market.merchium.ru/js/app.js'></script> <script> MerchiumApp.init({ appKey: '<?php echo MERCHIUM_APP_KEY; ?> ', shopDomain: '<?php echo $shop_domain; ?> ' }); MerchiumApp.ready(function()
<?php require '../MerchiumClient.php'; //define('MERCHIUM_DEBUG', true); define('MERCHIUM_APP_KEY', '[YOUR_APP_KEY]'); define('MERCHIUM_CLIENT_SECRET', '[YOUR_CLIENT_SECRET]'); if (!empty($_GET['code'])) { $shop_domain = $_GET['shop_domain']; $merchium = new MerchiumClient(MERCHIUM_APP_KEY, MERCHIUM_CLIENT_SECRET, $shop_domain); if ($merchium->validateSignature($_GET) != true) { echo "<p>Error validate signature</p>"; exit; } $access_token = $merchium->requestAccessToken($_GET['code']); if (empty($access_token)) { echo "<p>Error raised: " . $merchium->getLastError() . "</p>"; exit; } header("P3P: CP=\"Empty P3P policy\""); //IE third party cookie hack setcookie('merchium_shop_domain', $shop_domain, time() + 60 * 60 * 24 * 30, '/'); setcookie('merchium_access_token', $access_token, time() + 60 * 60 * 24 * 30, '/'); // // Redirect // header('Location: app.php'); exit; }