我想弄清楚一个PHP脚本来检查从一个单独的文本文件的链接一堆,如果他们中的任何人显示404然后脚本应该触发一个PHP文件,它会发送短信通知。我已经准备好了短信文件,只需触发即可。检查链接是否404,如果是,然后发送短信
例如,有在links.txt几个链接(也上载到服务器上),如
http://example.com/link1
http://example.com/link2
http://example.com/link3
这些链接不一定离线,它们可以被重定向到一个不存在的页面,而主要网站是活着的。
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
的参考smsnotice1.php,smsnotice2.php,smsnotice3.php可以是在主脚本或另一个PHP文件。
如果没有链接关闭,则不应发送通知。
我可以从一台cron上的php服务器上运行这个脚本进行频繁检查。 非常感谢您的帮助!
[你有什么尝试?](http://mattgemmell.com/2008/12/08/what-have-you-tried/) –
为什么不从[HTTP GET](http:// in1 .php.net/manual/en/function.http-get.php)?请尝试! – SparKot
用户'curl'发出请求,只返回头文件并对其进行评估。 – arkascha