Updating item in address list from php?

Hi everyone, .

I am looking to maintain a whitelist of ip’s for a firewall rule but I don’t want to maintain that list constantly. I plan to have a one-click webpage which will trigger an update to the list. The page will be a simple challenge/response and on submit will silently update the list if the response is valid. the intention is to locate a list entry by its comment and update the ip, never to add items.

I did some searches to see how I can interact with Router OS via PHP but couldn’t find anything useful. Does anyone here have some pointers that might help me?

Thanks

<?php
  require_once('routeros_api.class.php');
  $api = new RouterosAPI();
  if($api->connect('192.168.88.1', 'username', 'password')) {
    $api->write('/ip/firewall/address-list/print', false);
    $api->write('?comment=item1');
    $response = $api->read(true);
    if(!empty($response)) {
      $api->write('/ip/firewall/address-list/set', false);
      $api->write('=.id='.$response[0]['.id'], false);
      $api->write('=address=1.2.3.4');
      $response = $api->read(true);
    }
    $api->disconnect();
  }
?>

https://github.com/BenMenking/routeros-api

Amazing. Thanks a lot!