-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalert.php
37 lines (30 loc) · 1.05 KB
/
alert.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
<?php
include_once(__DIR__.'/mailer.php');
$file_path = 'last_job_link.txt';
//put RSS feed link here
$feed_link="PUT YOUR LINK HERE";
$xml_string = file_get_contents($feed_link);
$xml = simplexml_load_string($xml_string);
$firstJobLink = (string) $xml->channel->item[0]->link;
// If file exists and its content is different from the first job's link
if (file_exists($file_path) && file_get_contents($file_path) !== $firstJobLink) {
$output=null;
foreach ($xml->channel->item as $item) {
if ((string) $item->link === file_get_contents($file_path)) {
break;
}
$output .= "Title: " . $item->title . "<br/>";
$output .= "Link: " . $item->link . "<br/>";
//$output .= "Description: " . strip_tags($item->description) . "<br/>";
$output .= "-----------------------------<br/>";
}
if($output){
sendMail(['email'=>'', 'mail_body'=>"Upwork Jobs Alert:
<br/>".
$output
]);
}
}
// Store the first job's link in the file
file_put_contents($file_path, $firstJobLink);
?>