I am trying to figure out a php script to check a bunch of links from a separate text file and if anyone of them is showing 404 then the script should trigger a php file, which will send sms notification. I already have sms file ready and just need to trigger it.
For example, there are several links in links.txt (which is also uploaded on the server), such as
http://example.com/link1
http://example.com/link2
http://example.com/link3
These links are not necessarily offline, they may be redirecting to a non-existent page, while the main site is alive.
If example.com/link1 is down smsnotice1.php should be triggered
If example.com/link2 is down smsnotice2.php should be triggered
If example.com/link3 is down smsnotice3.php should be triggered
The reference to smsnotice1.php, smsnotice2.php, smsnotice3.php can be either in the main script or another php file.
If none of the links is down, then no notice should be sent.
I can run this script from a php server on a cron for frequent check. Thank you very much for the help!