You could look something like this command:
curl -k "https://ipv4.tunnelbroker.net/ipv4_end.php?ipv4b=
$IP is your IP address. If you are running this directly on the gateway you can get the IP address by piping the output of ifconfig through an appropriate sed command. If you are running this on a host behind a NAT the easiest is to use a webservice like http://myip.dnsomatic.com/
(make sure to pipe the output through something that will verify that it actually is a well formed IPv4 address, otherwise if the webservice you are using gets compromised it could be used to take control over your shell).
$UID is your user ID shown when logged in. This is a 32 digit hexadecimal number. $TUNNEL is your tunnel ID, this is a decimal number up to 6 digits so far.
Do you already know how to get the script to run when your IP changes? If you are running it on the gateway, then you can probably get the DHCP client to run a script when the address changes. Though I have seen at least one DHCP client claiming to run a command only when the address changes, but in reality run it every time it receives a DHCP response. If you are running it behind a NAT, then you'll just have to go through the steps to find your external address periodically and keep track of when it changes on your own.