Skip to content

Instantly share code, notes, and snippets.

@tomnomnom
Last active December 30, 2015 19:29
Show Gist options
  • Save tomnomnom/7874970 to your computer and use it in GitHub Desktop.
Save tomnomnom/7874970 to your computer and use it in GitHub Desktop.
Hacky FTTC Check Script
<?php
// Change me
const ADDRESS_ID = 'Gold|StringOfAlphas|MY|HouseNumber'; // You can find your Address ID using this: https://gist.github.com/TomNomNom/7875919
const TO_EMAIL = 'me@example.com';
const FROM_EMAIL = 'server@example.com';
// Don't change me
const SERVICE_URL = 'http://www.productsandservices.bt.com/consumerProducts/v1/productAvailability.do';
$query = http_build_query(array(
'addressId' => ADDRESS_ID,
'format' => 'json'
));
$r = file_get_contents(SERVICE_URL.'?'.$query);
$s = json_decode($r);
if (!$s){
sendMail("FTTC Check Script Failed", "Failed to parse JSON");
exit(1);
}
$message =
"Exchange name: {$s->exchangeName}\r\n".
"Service types available: \r\n";
$infinityAvailable = false;
foreach ($s->serviceLineTypes as $i => $lineType){
if ($lineType->infinity){
$infinityAvailable = true;
}
$message .= " #{$i} {$lineType->serviceLineType}\r\n";
}
if ($infinityAvailable){
sendMail("FTTC Available!", $message);
} else {
sendMail("FTTC Not Available", $message);
}
exit(0);
/////////
// Lib //
/////////
function sendMail($subject, $body){
$headers = 'From: ' .FROM_EMAIL. "\r\n";
mail(TO_EMAIL, $subject, $body, $headers);
}
@adamhepton
Copy link

You might want to factor in readyDate or risk getting your hopes up with a false positive, like I did :D

http://www.productsandservices.bt.com/consumerProducts/v1/productAvailability.do?telephone=01274885354&format=json is an example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment