Skip to content

Instantly share code, notes, and snippets.

@jamescridland
Created October 16, 2016 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamescridland/38f42dea0900ef605a9411e45a200063 to your computer and use it in GitHub Desktop.
Save jamescridland/38f42dea0900ef605a9411e45a200063 to your computer and use it in GitHub Desktop.
A quick check to see if Ofcom's txparams have updated themselves
<?php
// A small piece of code to check the Last-Modified header in PHP
// The below currently (on 16 October) returns:
// "Tue, 11 Oct 2016 11:26:59"
// ... so that's when it was last updated.
// I'm told that this URL is a permanent link. My assumption is that any update to the
// DAB, FM or AM data will produce an update for this main file; even though my own code
// actually just uses the .csv files.
$headers=get_headers('https://www.ofcom.org.uk/__data/assets/excel_doc/0017/91304/TxParams.xls',1);
echo $headers['Last-Modified'];
// Here's how I use the above, in pseudocode...
// SELECT last_modified FROM ofcom WHERE title='txparams'
// if (last_modified <> $headers['Last-Modified']) {
// then the txparams has changed
// send_mail ("Ofcom have updated their txparams!)
// UPDATE ofcom SET last_modified=$headers['Last-Modified'] WHERE title='txparams'
// }
// I then run the above script once a day.
// Probably most helpfully...
// If you'd like to get an email when Ofcom have updated their txparams, then
// I'd be very happy to add you to the little list. Mail me at james@cridland.net
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment