PHP code example of webwinkelkeur / client

1. Go to this page and download the library: Download webwinkelkeur/client 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/ */

    

webwinkelkeur / client example snippets


use WebwinkelKeur\Client;
use WebwinkelKeur\Client\Request;

$webwinkelKeurClient = new Client($id, $authToken);

$invitation = new Request\Invitation();
$invitation
    ->setCustomerName('John Doe')
    ->setEmailAddress('[email protected]')
    ->setPhoneNumbers(['+1.2024561111', '+1.2024561414'])
    ->setOrderNumber(184553)
    ->setOrderTotal(23.55);

try {
    $webwinkelKeurClient->sendInvitation($invitation);
    echo 'Success!';
} catch (Client\Exception $e) {
    echo $e->getMessage();
}

try {
    foreach ($webwinkelKeurClient->getSentInvitations() as $sentInvitation) {
        echo 'Invitation for order ' . $sentInvitation->getOrderNumber()
            . ' was sent on ' . $sentInvitation->getCreatedAt()->format('r')
            . ' to ' . $sentInvitation->getEmail() . "\n";
    }
} catch (Client\Exception $e) {
    echo $e->getMessage();
}

try {
    foreach ($webwinkelKeurClient->getRatings() as $rating) {
        echo $rating->getName() . ' says "' . $rating->getComment() . "\"\n";
    }
} catch (Client\Exception $e) {
    echo $e->getMessage();
}

try {
    $ratingsSummary = $webwinkelKeurClient->getRatingsSummary();
    echo 'The average rating is ' . $ratingsSummary->getRatingAverage()
        . ' out of ' . $ratingsSummary->getAmount() . " ratings.";
} catch (Client\Exception $e) {
    echo $e->getMessage();
}

try {
    $webshop = $webwinkelKeurClient->getWebshop();
    $address = $webshop->getAddress();
    echo $webshop->getName() . ' is located at '
        . $address->getNumber() . ' ' . $address->getStreet() . ', ' . $address->getCity();
} catch (Client\Exception $e) {
    echo $e->getMessage();
}

try {
    $richSnippet = $webwinkelKeurClient->getRichSnippet();
    echo $richSnippet;
} catch (Client\Exception $e) {
    echo $e->getMessage();
}