HamAlert: Push/SMS notifications for SOTA/RBN/Cluster spots

Hi Paul,

For each spot, HamAlert will make a request to the URL that you have entered, and includes all available information either as query parameters (GET mode), or in the form-encoded body (POST mode). The names of the parameters are according to the parameter list on the destinations page; only those parameters where the corresponding information is available in the spot will be included.

For the unique key, yes, something like that would work (and your script that accepts the incoming request should then check that the secret parameter is present and has the expected value). Or you could simply rename your endpoint (script path etc.) to something that cannot be guessed easily, e.g. https://www.w6png.com/hamalert_rk8mpx2gva. That way, if you receive a request at that URL, and provided that you don’t have directory listings or something similar turned on that would give away the list of endpoints/files/scripts, you can be pretty sure that the request came from HamAlert, since nobody else (aside from you and your web server of course) would know or be able to guess the exact URL.

I don’t know which language you are planning to use to write the program/script that will accept the spots on your web site. But let’s assume for a moment that it’s PHP, and since I get this question on how to process spots from HamAlert on a web site every now and then, let’s turn this into a mini-tutorial on how to do that with PHP, for the benefit of other users.

Mini tutorial on accepting HamAlert spots with PHP

  1. Create a new script file on your web host with an unguessable name, e.g. hamalert_rk8mpx2gva.php (example only, use a different secret filename of course :wink:). Contents see below.
  2. Enter the URL to the script on the destinations page of HamAlert, e.g. https://www.mywebsite.com/hamalert_rk8mpx2gva.php (assuming you have placed the script in the root directory of your web site). Select POST mode.
  3. Inside your script, you can now access the spot information like this:
<?php

$fullCallsign = $_POST['fullCallsign'];
$frequency = $_POST['frequency'];
$mode = $_POST['mode'];
$summitRef = @$_POST['summitRef']; // only present if a SOTA spot
// ...and so on for the other parameters of interest

// Now you would do something with the variables, e.g. store the spot in
// a database, send it to a social media platform, forward it through
// your favorite messenger's API, etc.

// As an example, let's just send an email:
if ($summitRef) {
    $subject = "SOTA Spot: $fullCallsign on $summitRef ($frequency $mode)";
} else {
    $subject = "Spot: $fullCallsign ($frequency $mode)";
}
// Include all POST parameters in body for reference
$body = print_r($_POST, true);

// Note: some web hosters may require additional headers or authentication
// in order to send email
mail("me@mywebsite.com", $subject, $body);

73,

Manuel HB9DQM

1 Like

Hi Manual (@HB9DQM)

Thanks for the response and that does help bring a little more clarity.

The language choice at present is Node Red which is primarily a graphical flow based language with easy ability to write functions etc in Javascript. Intellectually, programming languages are fascinating and while it’s been many a decade since someone paid me to program, at that time it was assembler and Algol like block structured languages. Node-Red’s simplicity and efficacy to create visual apps is appealing and I’ve managed to easily get data (such as Alerts) from SOTA Watch and Node-Red spoils “programmers” in hiding so much such that a simple built in node pretty much generates an array of alerts in JSON format. After a ton of reading, it’s someone easy peasy!!

I tried Jonathan’s @G4IVV www.ntfy.sh shell service and had a curl example up and running on my Mac via Terminal. Could send (via curl) a message to www.ntfy.sh/w6pngHamAlerts and subscribe to it in another Terminal running curl.

However, if I configure HamAlerts destination to https://nfty.sh/w6pngHamAlerts and then simulate a spot, I see nothing in my subscriber Mac Terminal window but do see the spot show up on my HamAlerts iPhone app.

This last weekend I participated in ARRL DX SSB with the intent of trying to flesh out DXCC phone and given CQWW WPX in 2 weeks thought I should construct a shopping list of DXCC entities that might be easy to get but I don’t have (for example SV1). It’s more than likely that HamAlerts configured with 20-30 shopping list items and the iPhone app buzzing away will be good enough versus me trying to do this programmatically. I sometimes view casual programming as my equivalent of Saduko or Wordly in that it keep the grey cells exercised.

I have the O’Reilly Definitive Guide to HTTP on my Kindle and its probably time to go read more of this than trying to hack by example (although that is a great approach to programming little things nowadays).

Any further pointers on getting it to work with www.ntfy.sh are welcome but as shared before, don’t feel compelled to educate.

HamAlerts is a good example of a clean and simple solution especially after perusing VE7CC stuff.

Paul

1 Like

Hi Paul,

I have never tried Node-RED myself, but sounds good, and there should be no problems processing HamAlert spot data with it :smile:

For HamAlert, URL notifications are just another type of action. So make sure you have the URL action checkbox checked in your triggers (and wait for a minute for changes to apply before you try it by simulating a spot).

73,

Manuel HB9DQM

1 Like

I didn’t do this and will try when home.

Thanks!!

Paul

1 Like

Bingo…

I received this

{“id”:“NCTH1MiP1Ghl”,“time”:1678392175,“expires”:1678435375,“event”:“message”,“topic”:“w6pngHamAlerts”,“message”:“fullCallsign=SV1ZZZ\u0026callsign=SV1ZZZ\u0026frequency=28.777\u0026band=10m\u0026mode=ssb\u0026modeDetail=ssb\u0026time=20%3A02\u0026spotter=M0SNA\u0026rawText=SIMULATED%20SPOT%3A%2020%3A02%20SV1ZZZ%20%2828.777%20SSB%29%2C%20from%20cluster%2C%20spotted%20by%20M0SNA%3A%20ZZTop%20in%20Greece\u0026title=SIMULATED%20spot%20SV1ZZZ%20%2828.777%20SSB%29\u0026comment=ZZTop%20in%20Greece\u0026source=cluster\u0026dxcc=236\u0026entity=Greece\u0026cq=20\u0026continent=EU\u0026homeDxcc=236\u0026homeEntity=Greece\u0026spotterDxcc=223\u0026spotterEntity=England\u0026spotterCq=14\u0026spotterContinent=EU\u0026triggerComment=”}

Paul

2 Likes

Here’s an unexpected plus in that my Apple watch automatically displays the iPhone alert.

2 Likes