-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.php
45 lines (36 loc) · 895 Bytes
/
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
<?php
use DieSchittigs\StarScraper\StarRating;
use DieSchittigs\StarScraper\GooglePlaceProvider;
use DieSchittigs\StarScraper\FacebookPageProvider;
use DieSchittigs\StarScraper\FakeRatingsProvider;
require 'vendor/autoload.php';
$starRating = new StarRating();
$starRating->addProvider(
new GooglePlaceProvider(
'{{GoogleApiKey}}',
'{{GoogleMapsPlaceID}}'
)
);
$starRating->addProvider(
new FacebookPageProvider(
'{{FacebookAppID}}',
'{{FacebookAppSecret}}',
'{{FacebookPageID}}'
)
);
$starRating->addProvider(
new FakeRatingsProvider([5,4,3,5,4])
);
$starRating->addProvider(
new FakeRatingsProvider([1,2,1,3,1,3])
);
$rating = $starRating->getRating();
print_r($rating);
echo '
"aggregateRating": {
"@type": "AggregateRating",
"bestRating": "'. $rating->bestRating .'",
"ratingCount": "'. $rating->ratingCount .'",
"ratingValue": "'. $rating->ratingValue .'"
}
';