ckdot / awin-product-sdk
An inofficial PHP SDK to grab product data from Awin.
0.0.2
2018-09-01 13:10 UTC
Requires
- php: ^7.0
- ext-mbstring: *
- ext-zlib: *
- guzzlehttp/guzzle: ^6.3
- symfony/cache: ^4.1
This package is not auto-updated.
Last update: 2025-03-05 23:53:30 UTC
README
An inofficial PHP SDK to grab product data from Awin.
Installation
composer require ckdot/awin-product-sdk
Usage
<?php use AwinProductSdk\ValueObjects\Advertiser; use AwinProductSdk\ValueObjects\Product; require_once 'vendor/autoload.php'; $apiKey = 'your-api-key'; $factory = new \AwinProductSdk\Factory\Factory(); $config = new \AwinProductSdk\ValueObjects\Config( 'https://productdata.awin.com/datafeed/list/apikey/' . $apiKey, new \Symfony\Component\Cache\Simple\FilesystemCache() ); $aWin = $factory->createFacade($config); $advertisers = $aWin->getAdvertisers(); $activeAdvertisers = $aWin->filterAdvertisers(Advertiser::KEY_STATUS, 'active', $advertisers); /** * @var Advertiser $advertiser */ foreach ($activeAdvertisers as $index => $advertiser) { $products = $aWin->getProducts($advertiser); $shirts = $aWin->filterProductsByRegExp(Product::KEY_NAME, '/shirt/i', $products); echo $advertiser->getId().': ' . $advertiser->getName() .PHP_EOL; /** * @var Product $shirt */ foreach ($shirts as $shirt) { echo '- ' . $shirt->getId() . ': ' . $shirt->getName().PHP_EOL; } }
How it works
The SDK is using the Awin product feed CSV files to read out advertiser and product data. Basically parsing of these data is quite fast but still you should be aware that some product feeds have a size of several megabytes. So I recommand to fetch data via SDK in background (cronjob) and store them into your own database. Make sure you set the memory limit of your PHP instance to a proper size.
Documentation
There is no documention. If you want to know how it works in detail, read the code.