-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathexample.php
135 lines (101 loc) · 3.36 KB
/
example.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
include __DIR__ . '/../src/vendor/autoload.php';
/**
* Settings
*/
$key = '<key>';
$productId = 415763024;
/**
* Init base class
*/
$scanner = new \MarketScanner\Scanner($key);
$balance = $scanner->getBalance();
// $balance = (new \MarketScanner\Model\Balance($key))->getBalance();
echo "<b>Balance</b><br>";
echo "Current: {$balance}<br>";
$info = $scanner->getInfo($productId);
// $info = new \MarketScanner\Model\Info($key, $productId);
echo "<b>Info</b><br>";
echo "Name: {$info->getName()}<br>";
echo "Price: {$info->getPrice()}<hr>";
$price = $scanner->getPrice($productId);
echo "<b>Only price</b><br>";
echo "Price: {$price->getPrice()}<br>";
echo "Price updated: {$price->getPriceUpdated()}<hr>";
echo '<b>Prices</b><br>';
$prices = $scanner->getPrices([415763024, 415763025]);
foreach ($prices as $priceIndex => $price) {
echo "{$priceIndex} => {$price->getPrice()}<br>";
}
echo '<hr>';
echo "<b>Search</b><br>";
$search = $scanner->getSearchModel('Туалетная бумага Veiro');
echo "ID: {$search->getId()}<br>";
echo "Name: {$search->getName()}<br>";
echo "URL: {$search->getUrl()}<hr>";
// All methods:
//
// $info->getName()
// $info->getUrl()
// $info->getCategoryId()
// $info->getBrandId()
// $info->getSpecsQuantity()
// $info->getReviewsQuantity()
// $info->getPhotosQuantity()
// $info->getRating()
// $info->getModof()
// $info->getPrice()
// $info->getPriceUpdated()
$reviews = $scanner->getReviews($productId, 10, 4);
// $reviews = $scanner->getReviews($productId);
echo "<b>Reviews:</b><br>";
foreach ($reviews as $review) {
echo $review->uid . '<br>';
echo $review->author . '<br>';
echo $review->avatar . '<br>';
echo $review->rating . '<br>';
echo $review->pluses . '<br>';
echo $review->minuses . '<br>';
echo $review->comment . '<br>';
echo $review->postdate . '<br>';
if ($review->pictures) {
foreach ($review->pictures as $picture) {
echo $picture . '<br>';
}
}
if ($review->subcomments) {
foreach ($review->subcomments as $subcommentIndex => $subcomment) {
echo $subcomment->author . '<br>';
echo $subcomment->comment . '<br>';
echo $subcomment->postdate . '<br>';
echo $subcomment->avatar . '<br>';
}
}
echo '<hr>';
}
$photos = $scanner->getPhotos($productId);
// $photos = $scanner->getPhotos($productId, '50x50');
// $photos = (new \MarketScanner\Model\Photos($key, $productId))->getPictures('original');
echo "<b>Photos</b><br>";
foreach ($photos as $photoNumber => $photoCollection) {
foreach ($photoCollection as $photoItem) {
echo $photoItem->size . ' ' . $photoItem->url . '<br>';
}
echo "<br>";
}
echo "<hr>";
$specs = $scanner->getSpecs($productId);
// $specs = (new \MarketScanner\Model\Specs($key, $productId))->getSpecifications();
echo "<b>Specifications</b><br><br>";
foreach ($specs as $specNumber => $specCollection) {
foreach ($specCollection as $specCollectionNumber => $specCollectionItem) {
if (is_string($specCollectionItem)) {
echo '<b>' . $specCollectionItem . '</b><br>';
}
if (is_array($specCollectionItem)) {
foreach ($specCollectionItem as $specCollectionItemParams) {
echo $specCollectionItemParams->name . ' - "' . $specCollectionItemParams->value . '"<br>';
}
}
}
}