-
Notifications
You must be signed in to change notification settings - Fork 1
/
Coupons.php
55 lines (55 loc) · 1.66 KB
/
Coupons.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
<?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;
}
$URL='http://pubapi.yp.com/search-api/search/devapi/coupons?format=json&key=0z02n4301r&searchloc=91203';
$JSON= get_content($URL);
$array=json_decode($JSON,true);
$searchlisting= $array["searchResult"]["searchListings"]["searchListing"];
foreach($searchlisting as $i){
if(isset($i['businessName'])&&$i['businessName']!==''&&isset($i['couponURL'])&&$i['couponURL']!==''){
$name= $i["businessName"];
$url= $i["couponURL"];
echo"   <a href='$url'>$name </a><br>";
}
elseif(isset($i['businessName'])&&$i['businessName']!==''){
$name= $i["businessName"];
echo"    $name<br>";
}
if(isset($i['websiteURL'])&&$i['websiteURL']!==''){
$website= $i["websiteURL"];
echo"<a href='$website'>Website </a><br>";
}
if(isset($i['city'])&&$i['city']!==''){
$city= $i["city"];
echo"City: $city <br>";
}
if(isset($i['couponCount'])&&$i['couponCount']!==''){
$count=$i["couponCount"];
echo"Count: $count <br>";
}
if(isset($i['phone'])&&$i['phone']!==''){
$phone=$i["phone"];
echo"Phone: $phone<br>";
}
if(isset($i['state'])&&$i['state']!==''){
$state=$i["state"];
echo"State: $state<br>";
}
if(isset($i['street'])&&$i['street']!==''){
$street=$i["street"];
echo"Street: $street<br><br><br>";
}
}
?>
<html>
<head>
<title> coupons </title>
</head>
</html>