-
Notifications
You must be signed in to change notification settings - Fork 3
/
examples.php
73 lines (49 loc) · 1.88 KB
/
examples.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
* eKomi PHP library by flowl.info
*
* @author Daniel Wendler
* @see http://blog.flowl.info/2014/ekomi-php-library/
* @license https://github.com/flowl/ekomi/blob/master/LICENSE
* @package eKomi
*/
include('eKomi/eKomi.php');
// Instance a new eKomi object:
$ekomi = new eKomi\eKomi;
// Set the interfaceID and password credentials
// and wether you'd like to use https or http.
$ekomi->setUsername('xxxxx')
->setPassword('xxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
->setForceHttps(true);
// Instance a new Product object.
// Keep in mind that eKomi serves the review page
// using ISO encoding, do not put multibyte (UTF-8)
// characters into the product name.
// The picture must be served using https with a maximum
// width and height of 150px x 150px
$product = new eKomi\Product;
$product->setProductId('10099921')
->setProductName('Nike Airmax 90s Limited, white, 41')
->setProductImage('https://www.yourdomain.com/images/10099921_small.jpg');
// Using the eKomi instance,
// you can register the former Product.
// This returns true or false respectively.
$ekomi->putProduct($product);
// Let's have a new Order
// and put in the Product we already registered.
$order = new eKomi\Order;
$order->setOrderId('999')
->addProduct($product);
// Since PHP 5.4 you can also do the following
// to add a Product to an Order:
$order->addProduct((new eKomi\Order)->setProductId('1234-5678')->setProductName(/* ... */)->setProductImage(/* ... */));
// Push the order to the eKomi API
$ekomi->putOrder($order);
// If this succeeded (returns true or false),
// the order has a review link:
echo $order->getReviewLink();
// To fetch product feedback:
while ($productFeedback = $ekomi->getProductFeedback()) {
echo 'Product ID: ' . $productFeedback->getProductId() . ' ',
'Rating: ' . $productFeedback->getRating() . '<br />', PHP_EOL;
}