$client->secret = 'simsalabim';
$productsService = new \Productsup\Service\ProductData($client);
// reference to the site you want to add or delete products for, for a more detailed description @see /examples/Service/Sites.php
$reference = new \Productsup\Platform\Site\Reference();
$reference->setKey('MyTestReference');
$reference->setValue('TestId');
$productsService->setReference($reference);
/**
 * one example with all fields supported by the content API for shopping. Not all of the fields are required,
 * only the "id" column is mandatory.
 *
 * note: the field names are similar to the content API, but may be slightly different
 */
$product = array('id' => 1, 'additionalImageLink' => 'http://example.com/img/1.jpg,http://example.com/img/2.jpg', 'adult' => 1, 'adwords_grouping' => '', 'adwords_labels' => '', 'adwords_redirect' => '', 'age_group' => 'adult', 'availability' => 'in stock', 'availability_date' => '2014-12-01', 'brand' => 'my brand', 'color' => 'red', 'condition' => 'new', 'custom_label_0' => 'custom label 0', 'custom_label_1' => 'custom label 1', 'custom_label_2' => 'custom label 2', 'custom_label_3' => 'custom label 3', 'custom_label_4' => 'custom label 4', 'description' => 'describes my product', 'energy_efficiency_class' => '', 'expiration_date' => '', 'gender' => 'male', 'google_product_category' => '', 'gtin' => '', 'identifier_exists' => '', 'image_link' => 'http://example.com/img/default.jpg', 'is_bundle' => '', 'item_group_id' => '', 'link' => 'http://example.com/product.html', 'material' => '', 'mobile_link' => 'http://m.example.com/product.html', 'mpn' => '', 'multipack' => '', 'online_only' => '', 'pattern' => '', 'price' => '90.90 EUR', 'product_type' => '', 'sale_price' => '12.34 EUR', 'sale_price_effective_date' => '', 'shipping' => 'DE::DHL:5.00 EUR,AT::Express:19.50', 'shipping_label' => '', 'size_system' => '', 'size_type' => '', 'size' => '', 'title' => 'example product');
try {
    $productsService->insert($product);
    $productsService->commit();
} catch (\Productsup\Exceptions\ServerException $e) {
    // A exception at the API Server happened, should not happen but may be caused by a short down time
    // You may want to retry it later, if you keep getting this kind of exceptions please notice us.
    throw new Exception('Error at the productsup API, retry later');
} catch (\Productsup\Exceptions\ClientException $e) {
    // Most likely some of the data you provided was malformed
    // The error codes follow http status codes, @see http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Client_Error
    // The message may give more information on what was wrong:
    echo $e->getCode() . ' ' . $e->getMessage();
} catch (\Exception $e) {
    // Exceptions not within the Productsup namespace are not thrown by the client, so these exceptions were most likely
    // thrown from your application or another 3rd party application
    // however, if you don't catch Productsup exceptions explicitly, you can catch them all like this
    echo $e->getCode() . ' ' . $e->getMessage();
$reference->setValue('TestId');
$siteObject->addReference($reference);
$siteObject = $siteService->insert($siteObject);
/**
 * To enable an export to a Google Content API, you can use the "exports service":
 */
$exportService = new \Productsup\Service\Exports($client);
/**
 * adding a reference to the site you want to export:
 * for more information on how references in services work, @see /examples/Service/ProductData.php
 */
$Reference = new \Productsup\Platform\Site\Reference();
$Reference->setKey('MyTestReference');
$Reference->setValue('TestId');
$exportService->setReference($Reference);
/**
 * enableContentApi enables the export to one of your merchant centers
 *
 * note: it is mandatory to authorize the "parent id" via OAuth at http://platform.productsup.com/ before you enable exports
 */
$exportService->enableContentApi('1234', '4321', 'de', 'de');
/**
 * From now on, you can upload products to this site:
 *
 * For more detailed explanation on the product service
 * @see /examples/Service/ProductData.php and @see /examples/migrateContentAPI/addingProducts.php
 */
$productsService = new \Productsup\Service\ProductData($client);
$productsService->insert(array('id' => 1, 'title' => 'my first product', 'description' => 'this is the first product', 'price' => 99.90000000000001));
$productsService->delete(array('id' => 1));
$productsService->commit();
 * a delta import is used to update the latest full import
 *
 * note: one import/service has only one type
 */
//$ProductService->setImportType(\Productsup\Service\ProductData::TYPE_FULL);
$ProductService->setImportType(\Productsup\Service\ProductData::TYPE_DELTA);
/** 
 * Adding one product to insert.
 *
 * A product is represented by an array.
 * There is no fixed structure you have to follow,
 * the keys you use will become the column name for the resulting upload
 *
 * note: you have to call commit() at the end before the data actually gets handled
 */
$ProductService->insert(array('id' => 123, 'price' => 39.9, 'description' => 'some text'));
$ProductService->insert(array('id' => 124, 'price' => 99.98999999999999, 'description_de' => 'ein text'));
// adding 5000 random "products"
for ($i = 0; $i < 5000; $i++) {
    $ProductService->insert(array('id' => uniqid(), 'test' => md5(uniqid()), 'created' => microtime(true), 'price' => mt_rand(0, 1000000) / 100));
}
/**
 * deleting products works the same as inserting products:
 */
$ProductService->delete(array('id' => 123));
/**
 * if you added all products, call commit to start the processing:
 *
 * note: you may not insert or delete products after the submit.
 * if you have more products to insert, please create a new service
 */