PHP code example of epages / rest-sdk

1. Go to this page and download the library: Download epages/rest-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

epages / rest-sdk example snippets


{
   " "epages/rest-sdk": ">=0.2"
    }
}


ep6\Logger::setLogLevel(ep6\LogLevel::NOTIFICATION);	// activate visible output

// set connection constants
$HOST		= "www.meinshop.de";
$SHOP		= "DemoShop";
$AUTHTOKEN	= "xyzxyzxyzxyzxyzxyzxyzxyz";
$ISSSL		= true;

// connect to shop
$shop = new ep6\Shop($HOST, $SHOP, $AUTHTOKEN, $ISSSL);

// use a product filter to search for products
$productFilter = new ep6\ProductFilter();
$productFilter->setLocale("de_DE");
$productFilter->setCurrency("EUR");
$productFilter->setSort("name");
$productFilter->setResultsPerPage(100);
$products = $productFilter->getProducts();

// print the products
foreach ($products as $product) {

    echo "<h2>" . htmlentities($product->getName()) . "</h2>";
    echo "<p>";
    echo "<img style=\"float:left\" src=\"" . $product->getSmallImage()->getOriginURL() . "\"/>";
    echo "<strong>ProductID:</strong> " . $product->getID() . "<br/>";
    echo "<strong>Description:</strong> " . htmlentities($product->getDescription()) . "<br/><br/>";
    echo "<strong>This product is ";
    if (!$product->isForSale()) {
        echo "NOT ";
    }
    echo "for sale and is ";
    if ($product->isSpecialOffer()) {
        echo "<u>a</u> ";
    }
    else {
        echo "not a ";
    }
    echo "special offer.</strong>";
    echo "</p><hr style=\"clear:both\"/>";
}


ep6\Logger::setLogLevel(ep6\LogLevel::NOTIFICATION);	//activate visible output

// set connection constants
$HOST		= "www.meinshop.de";
$SHOP		= "DemoShop";
$AUTHTOKEN	= "xyzxyzxyzxyzxyzxyzxyzxyz";
$ISSSL		= true;

// connect to shop
$shop = new ep6\Shop($HOST, $SHOP, $AUTHTOKEN, $ISSSL);

// prints the default currency and localization
echo $shop->getDefaultLocales();
echo $shop->getDefaultCurrencies();

// prints the name of the contact information in default language and in german
$contactInformation = $shop->getContactInformation();
echo $contactInformation->getDefaultName();
echo $contactInformation->getName();

ep6\Logger::force("Print this!");

ep6\Logger::setLogLevel(ep6\LogLevel::NOTIFICATION);	// shows all messages
ep6\Logger::setLogLevel(ep6\LogLevel::WARNING);			// shows warning and error messages
ep6\Logger::setLogLevel(ep6\LogLevel::ERROR);			// shows only error messages
ep6\Logger::setLogLevel(ep6\LogLevel::NONE);			// don't log anything

ep6\InputValidator::isHost("www.test.de");
ep6\InputValidator::isJSON("{}");
echo