Example #1
0
        //MerchiumApp.Bar.remove(['new', 'prev']);
    });
</script>
</head>
<body>
<?php 
echo "<p>ADMIN AREA</p>";
echo "<pre>";
echo "<p>Token: {$access_token}<br> Shop: {$shop_domain}</p>";
echo "<p>Lets send some test requests:</p>";
//
// Send Create
//
$res = $merchium->createRequest('products', array('product_code' => 'test', 'product' => 'Test product', 'price' => '25.0', 'company_id' => 1, 'status' => 'A', 'main_category' => '166', 'category_ids' => array('166')));
if ($res === false) {
    echo "<p>Error raised on create request: <b>" . $merchium->getLastError() . "</b></p>";
    exit;
}
$new_product_id = $res['product_id'];
echo "<p>Product with product_id={$new_product_id} was successfully created.</p>";
//
// Send Update
//
$res = $merchium->updateRequest("products/{$new_product_id}", array('price' => 2500.0));
if ($res === false) {
    echo "<p>Error raised on update request: <b>" . $merchium->getLastError() . "</b></p>";
    exit;
}
echo "<p>Price for product with product_id={$res['product_id']} was successfully updated.</p>";
//
// Send
Example #2
0
<?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;
}