-
Notifications
You must be signed in to change notification settings - Fork 1
/
viewReviews.php
45 lines (43 loc) · 1.06 KB
/
viewReviews.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
function get_content($URL){
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
if(!empty($_GET['id'])){
$id= $_GET['id'];
$URL='http://pubapi.yp.com/search-api/search/devapi/reviews?listingid='.urlencode($id).'&key=0z02n4301r&format=json';
$JSON= get_content($URL);
$array=json_decode($JSON,true);
}
?>
<html>
<head>
<title> reviews </title>
</head>
<body>
<form action="" >
<?php
$reviews=$array['ratingsAndReviewsResult']['reviews'];
if(!isset($reviews['review'])){
echo "No reviews exist";
}else
{
$reviews=$reviews['review'];
foreach($reviews as $i){
$rating=$i['rating'];
echo "Rate: $rating<br>";
$body=$i["reviewBody"];
echo"Review: $body<br>";
$reviewer=$i["reviewer"];
echo "Reviewer : $reviewer<br>";
}
}
?>
</form>
</body>
</html>