-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScheduled_Check.php
More file actions
56 lines (45 loc) · 1.52 KB
/
Copy pathScheduled_Check.php
File metadata and controls
56 lines (45 loc) · 1.52 KB
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
<?php
//phpinfo();
$con=mysqli_connect("localhost","gplusbus","Akshar11!!","gplusbus_Deals");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM Zappos_users");
if($result === FALSE) {
die(mysql_error()); // TODO: better error handling
}
while($row = mysqli_fetch_array($result))
{
//echo $row['Email'] . " " . $row['Product_ID'];
$url= "http://api.zappos.com/Product/".$row['Product_ID']."?includes=[%22styles%22]&key=a73121520492f88dc3d33daf2103d7574f1a3166"; // connect to the API and get the data
$response = @file_get_contents($url);
if($response === false)
{
// do nothing
}
else{
$decoded_json=json_decode($response, true); // Decode the Json data fetched from API
$discount = explode("%",$decoded_json['product'][0]['styles'][0]['percentOff']);
if(intval($discount[0])>=20)
{
// send email to the user if discount is equal to or greater than 20%
$to = $row['Email'];
$subject = "Sample Email notification";
$body = "Hi this is the testing email !";
$headers = "From: parth@gplusbusinessapps.com\r\n"."X-Mailer: php";
if (mail($to, $subject, $body, $headers))
{
echo("<p>Message sent!</p>");
}
else
{
//echo("<p>Message delivery failed...</p>");
}
exit;
}
}
}
mysqli_close($con);
?>