RouterOS 7 (REST API) example in PHP
Lamp server Mikrotik router running RouterOS 7 Enable www-ssl service and install CA certificate
Clone ros-rest-php repo
git clone https://github.com/ngangavic/ros-rest-php.git
Set your router username, password and url in exec.php
.
$secrets = [
"username" => "your-username",
"password" => "your-password",
"url" => "router-url/rest"
];
Initialize the class
$ros7=new ROS7Rest($secrets);
Pass the command path
$ros7->path="/interface/print";//REST API url
Pass the POST data
$ros7->requestData='{".proplist":["name","type"]}';//send post data
Make requests(Responses are in JSON format)
$res=$ros7->ros7POST();//post request
$res=$ros7->ros7GET();//get request
$res=$ros7->ros7PUT();//get put request
$res=$ros7->ros7DELETE();//get delete request
$res=$ros7->ros7PATCH();//get patch request