1. Go to this page and download the library: Download znojil/heureka 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/ */
znojil / heureka example snippets
use Znojil\Heureka\Client;
use Znojil\Heureka\Enum\Region;
// For Heureka.cz
$clientCz = new Client(Region::Cz, 'YOUR_API_KEY_FOR_CZ');
// For Heureka.sk
$clientSk = new Client(Region::Sk, 'YOUR_API_KEY_FOR_SK');
use Znojil\Heureka\Client;
use Znojil\Heureka\Enum\Region;
use Znojil\Heureka\Http\Client as HeurekaHttpClient;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\UriInterface;
// A custom HTTP client implementation example
class MyCustomHttpClient implements HeurekaHttpClient{
public function send(string $method, UriInterface|string $uri, array $headers = [], mixed $data = null, array $options = []): ResponseInterface{
// your implementation
}
}
$customHttpClient = new MyCustomHttpClient;
$client = new Client(Region::Cz, 'YOUR_API_KEY', $customHttpClient);
use Znojil\Heureka\Feed\Request\GetCategoryTreeRequest;
$request = new GetCategoryTreeRequest;
$categoryTreeCollection = $clientCz->send($request);
foreach($categoryTreeCollection as $tree){
$tree; // CategoryTreeDTO
}
use Znojil\Heureka\Feed\Request\GetShopReviewsRequest;
$request = new GetShopReviewsRequest;
$reviews = $clientCz->send($request);
foreach($reviews as $review){
$review; // ShopReviewDTO
}
use Znojil\Heureka\Feed\Request\GetProductReviewsRequest;
// Without a date filter
$requestAll = new GetProductReviewsRequest;
$allReviews = $clientCz->send($requestAll);
// Only reviews since yesterday
$yesterday = new \DateTimeImmutable('yesterday');
$requestSince = new GetProductReviewsRequest($yesterday);
$recentReviews = $clientCz->send($requestSince);
use Znojil\Heureka\ShopCertification\LogOrderDTO;
use Znojil\Heureka\ShopCertification\OrderLogRequest;
// 1. Create a DTO with the order data
$orderDto = new LogOrderDTO(
email: '[email protected]',
orderId: 'ORD2024001',
productItemIds: ['AB-123', 'CD-456']
);
// 2. Create the request and send it
$request = new OrderLogRequest($orderDto);
$response = $clientCz->send($request);
if($response->isSuccessful()){
echo "Order was successfully logged.";
}
use Znojil\Heureka\Exception\ClientException;
use Znojil\Heureka\Exception\ResponseException;
use Znojil\Heureka\Exception\ServerException;
try{
$response = $client->send(new OrderLogRequest($orderDto));
}catch(ClientException $e){
// HTTP client error (4xx)
echo $e->getMessage(); // error details from Heureka
echo $e->getCode(); // HTTP status code
}catch(ServerException $e){
// Heureka server error (5xx)
}catch(ResponseException $e){
// any other unexpected HTTP status
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.