Community discussions

MikroTik App
 
rafiqkuet
just joined
Topic Author
Posts: 2
Joined: Wed May 12, 2021 5:29 pm
Location: Dhaka, Bangladesh
Contact:

Delete PPP user from Secrets using PHP API

Wed May 26, 2021 5:04 pm

I want to delete PPP user from Secrets.
I have a workable command for PEAR2\Net\RouterOS:
/ppp secret remove numbers=$username

Now, I need compatible code for routeros_api.class.php

The below is my code which is not working:

require '../routeros_api.class.php';
$API = new RouterosAPI();
$API->debug = true;

$username  = "TEST"; // asumig this user already added in PPP secrets
if ($API->connect('111.111.111.111', 'LOGIN', 'PASSWORD')) 
{	
	$arrID = $API->comm(
		"/ppp/active/getall",
		array(  
			".proplist"=> ".id",
			"?name" => $username,
		)
	);
	
	// This commad is not working
	$API->comm(
		"/ppp/secret/remove",
		array(
			".id" => $arrID[0][".id"],
		)
	);    
	
	$API->disconnect();
}
Any help would be greatly appreciated.
 
rafiqkuet
just joined
Topic Author
Posts: 2
Joined: Wed May 12, 2021 5:29 pm
Location: Dhaka, Bangladesh
Contact:

Re: Delete PPP user from Secrets using PHP API  [SOLVED]

Sat May 29, 2021 4:12 am

I could fix the problem, "/ppp/active/getall" have to replace with "/ppp/secret/getall".

Here is the workable code:
require '../routeros_api.class.php';
$API = new RouterosAPI();
$API->debug = true;

$username  = "TEST"; // asumig this user already added in PPP secrets
if ($API->connect('111.111.111.111', 'LOGIN', 'PASSWORD')) 
{	
	$arrID = $API->comm(
		"/ppp/secret/getall",
		array(  
			".proplist"=> ".id",
			"?name" => $username,
		)
	);
	
	$API->comm(
		"/ppp/secret/remove",
		array(
			".id" => $arrID[0][".id"],
		)
	);    
	
	$API->disconnect();
}

Who is online

Users browsing this forum: donkeyKong and 26 guests