Langsung ke konten utama

Postingan

Menampilkan postingan dari September, 2023

add or remove address-list mikrotik using rest API with PHP

<?php if($_GET['action'] == 'add'){     function setupCurl($url, $requestType, $postData = null) {         $ch = curl_init();         curl_setopt($ch, CURLOPT_URL, $url);         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $requestType);         curl_setopt($ch, CURLOPT_USERPWD, 'admin' . ':' . '123456');         curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);              if ($postData) {             curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);         }              return $ch;     }          $ch = setupCurl('https://10.10.33.21:4433/rest/ip/firewall/address-list', 'PUT', '{"address": "1.2.3.4", "list": "list-pelanggan"}');     $result = curl_exec($ch);          if (curl_errno($ch)) {