From 63c0d7ed8cfb6bcbd087792c690a874b0e0a962c Mon Sep 17 00:00:00 2001 From: pineros <61841991+pineros@users.noreply.github.com> Date: Thu, 2 Nov 2023 12:29:58 -0400 Subject: [PATCH 1/5] Managed by Terraform From ad09b66871589a12d1ce175727bf8ca91bb3a6dd Mon Sep 17 00:00:00 2001 From: pineros <61841991+pineros@users.noreply.github.com> Date: Thu, 9 Nov 2023 16:04:32 -0500 Subject: [PATCH 2/5] Managed by Terraform From 2f148da2131318ae08ac15fd1dac259ffc96984e Mon Sep 17 00:00:00 2001 From: pineros <61841991+pineros@users.noreply.github.com> Date: Tue, 14 Nov 2023 11:16:53 -0500 Subject: [PATCH 3/5] Managed by Terraform From 5d77fd60c1f434ed17a18ad55b294953a82356b2 Mon Sep 17 00:00:00 2001 From: pineros <61841991+pineros@users.noreply.github.com> Date: Tue, 14 Nov 2023 16:07:11 -0500 Subject: [PATCH 4/5] Managed by Terraform From 72b2538b6b27ad98fd0254e7a4e4780735a599e0 Mon Sep 17 00:00:00 2001 From: William Tam Date: Wed, 31 Jan 2024 16:38:49 -0500 Subject: [PATCH 5/5] v0.95 make state lookup work --- classes/class-pbs-check-dma.php | 25 +++++++++++++++++++++++++ pbs-check-dma.php | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/classes/class-pbs-check-dma.php b/classes/class-pbs-check-dma.php index d867446..01d262e 100644 --- a/classes/class-pbs-check-dma.php +++ b/classes/class-pbs-check-dma.php @@ -329,6 +329,31 @@ public function list_available_station_ids_in_zipcode($zipcode) { return $available_station_ids; } + public function list_available_station_ids_in_state($state) { + if (empty($state) || !(preg_match('/^([A-Z]{2})?$/', $state))) { + // zipcode is either empty or isn't 2 letters + return false; + } + $callsign_url = "https://services.pbs.org/stations/state/"; + $combined_url = $callsign_url . $state . '.json'; + $response = wp_remote_get($combined_url, array()); + if (! is_array( $response ) || empty($response['body'])) { + return array('errors' => $response); + } + $body = $response['body']; // use the content + $parsed = json_decode($body, TRUE); + $available_station_ids = []; + foreach($parsed['$items'] as $key) { + $link = $key['$links'][0]; + if (isset($link['pbs_id'])) { + $station_id = $link['pbs_id']; + array_push($available_station_ids, $station_id); + } + } + return $available_station_ids; + } + + public function list_localization_states() { $services_endpoint = "https://services.pbs.org/states.json"; $response = wp_remote_get($services_endpoint, array()); diff --git a/pbs-check-dma.php b/pbs-check-dma.php index d75094f..ea87122 100644 --- a/pbs-check-dma.php +++ b/pbs-check-dma.php @@ -1,7 +1,7 @@