API in Visual Basic 6 working fine!
RouterOS general discussion

23 posts   •   Page 1 of 1
lucho512
just joined
 
Posts: 13
Joined: Tue Aug 17, 2010 12:21 am

API in Visual Basic 6 working fine!

by lucho512 » Mon May 09, 2011 7:52 pm

hi forum, after much searching, I found an example for the management of the api in vb6 posted by Royce3, after some minor alterations to make to achieve it to work well, AUI I leave so they can experience and that You will not find any echo in vb6 to handle the api. I hope this will be useful, and discuss their progress, I keep working !!!..

Greetings.
Attachments
TESTAPIVB6.JPG
TESTAPIVB6.JPG (28.86 KiB) Viewed 7462 times
MKT API Test.rar
(11.37 KiB) Downloaded 2798 times

SamWCL
Frequent Visitor
Frequent Visitor
 
Posts: 69
Joined: Mon Apr 20, 2009 1:18 pm
Location: Wellington/Auckland, New Zealand

Re: API in Visual Basic 6 working fine!

by SamWCL » Mon May 09, 2011 8:31 pm

good job!
News Cameraman / Build rural networks on slow news days.
New Zealand

inibir
Member Candidate
Member Candidate
 
Posts: 113
Joined: Thu Nov 25, 2010 3:25 pm
Location: lebanon

Re: API in Visual Basic 6 working fine!

by inibir » Tue Sep 06, 2011 10:32 am

its not work

his return this msg

Code: Select all
(Connecting)
ws_Error: Connection is forcefully rejected

User avatar
normis
MikroTik Support
MikroTik Support
 
Posts: 19286
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: API in Visual Basic 6 working fine!

by normis » Tue Sep 06, 2011 11:55 am

inibir wrote:its not work

his return this msg

Code: Select all
(Connecting)
ws_Error: Connection is forcefully rejected



did you enable the API on RouterOS?
No answer to your question? How to write posts

inibir
Member Candidate
Member Candidate
 
Posts: 113
Joined: Thu Nov 25, 2010 3:25 pm
Location: lebanon

Re: API in Visual Basic 6 working fine!

by inibir » Thu Sep 08, 2011 10:28 pm

took 9 months trying to fix it, I knew I had to do to enable the API

tanks normis

User avatar
kurei
just joined
 
Posts: 24
Joined: Tue Aug 11, 2009 9:29 am

Re: API in Visual Basic 6 working fine!

by kurei » Mon Oct 10, 2011 11:48 am

WORKS PERFECTLY !!!

I've learned java and VB.NET, but I think, I'm still loving this classic things.

Spend one year to make API in visual basic, but I got nothing. :lol:

User avatar
lucubrb
just joined
 
Posts: 1
Joined: Sat Nov 05, 2011 6:00 pm
Location: localhost - 127.0.0.1

Re: API in Visual Basic 6 working fine!

by lucubrb » Sat Nov 05, 2011 6:06 pm

inibir wrote:its not work

his return this msg

Code: Select all
(Connecting)
ws_Error: Connection is forcefully rejected


ip - service

did you enable api?

i used ros 5.8 and working properly.

Great job, TS.

DorisLam
just joined
 
Posts: 1
Joined: Wed Aug 31, 2011 12:34 am

Re: API in Visual Basic 6 working fine!

by DorisLam » Thu Apr 12, 2012 3:16 pm

The script is working fine for me, the API is enabled and I can log in the router.

When I click SEND, I can see the same results. The probleme is when I click again on SEND, I get the OLD result + the new one. I cleared the text field before clicking SEND (txtout.text=""), but same problem. It seem the buffer is not clearing after the command is executed. I suspect the inbuf1 variable.


Thanks for your help

ax045Y
just joined
 
Posts: 8
Joined: Sat Apr 21, 2012 11:30 pm

Re: API in Visual Basic 6 working fine!

by ax045Y » Sat Apr 21, 2012 11:33 pm

is this script run correcly at v 5.12?

lucho512
just joined
 
Posts: 13
Joined: Tue Aug 17, 2010 12:21 am

Re: API in Visual Basic 6 working fine!

by lucho512 » Sun Apr 22, 2012 2:01 am

ax045Y wrote:is this script run correcly at v 5.12?


Yes, working fine!!!

ax045Y
just joined
 
Posts: 8
Joined: Sat Apr 21, 2012 11:30 pm

Re: API in Visual Basic 6 working fine!

by ax045Y » Tue Apr 24, 2012 9:25 pm

lucho512 wrote:
ax045Y wrote:is this script run correcly at v 5.12?


Yes, working fine!!!

what wrong with mine?
its error when copile to make .exe file

Image

ditonet
Forum Veteran
Forum Veteran
 
Posts: 764
Joined: Mon Oct 19, 2009 12:52 am
Location: Europe/Poland/Konstancin-Jeziorna

Re: API in Visual Basic 6 working fine!

by ditonet » Tue Apr 24, 2012 11:55 pm

@ax045Y
Do not use Package and Deployment Wizard to compile project, use VB6 IDE 'File/Make...' command instead.
In this case compiler shows you what and where is wrong with code.
This API example works fine, problem is with 'CRAM_MD5' function in 'MD5.cls'.
Remove this function and you will be able to compile this example to .EXE.

HTH,
Grzegorz | IT Warszawa

ax045Y
just joined
 
Posts: 8
Joined: Sat Apr 21, 2012 11:30 pm

Re: API in Visual Basic 6 working fine!

by ax045Y » Thu Apr 26, 2012 1:21 pm

ditonet wrote:@ax045Y
Do not use Package and Deployment Wizard to compile project, use VB6 IDE 'File/Make...' command instead.
In this case compiler shows you what and where is wrong with code.
This API example works fine, problem is with 'CRAM_MD5' function in 'MD5.cls'.
Remove this function and you will be able to compile this example to .EXE.

HTH,

:D
thanks..
anyway i have new problem.
what command to enable user?

Image

hmm,,
so this api just can do 1 line command?

bastakboys
just joined
 
Posts: 1
Joined: Tue Oct 09, 2012 8:15 am

Re: API in Visual Basic 6 working fine!

by bastakboys » Tue Oct 09, 2012 8:39 am

do you have a vb.net source

amongdota
just joined
 
Posts: 2
Joined: Thu Aug 22, 2013 11:51 am

Re: API in Visual Basic 6 working fine!

by amongdota » Thu Aug 22, 2013 12:31 pm

Thanx lucho512 good job

DorisLam wrote:The script is working fine for me, the API is enabled and I can log in the router.

When I click SEND, I can see the same results. The probleme is when I click again on SEND, I get the OLD result + the new one. I cleared the text field before clicking SEND (txtout.text=""), but same problem. It seem the buffer is not clearing after the command is executed. I suspect the inbuf1 variable.


Thanks for your help


Doris, i have your problem also, and after a hours i got this

change this
Code: Select all
Private Sub ws_DataArrival(ByVal sent$)
.
.
.
end sub


into this
Code: Select all
Private Sub ws_DataArrival(ByVal bytesTotal As Long)
    If bErr Then Exit Sub
    Dim ar() As Byte, i&
    ReDim ar(0 To bytesTotal - 1)
    ws.GetData ar, vbByte, bytesTotal
    On Error Resume Next
    Err.Clear
    On Error GoTo 0
    inbuf1 = ar
    Dim WordLen&, StartIdx&, Idx&
    StartIdx = 0
    Do While True
        Idx = StartIdx
        WordLen = CalcWordLen(inbuf1, Idx)
        If WordLen < 0 Then
            Exit Do
        End If
        If WordLen = 0 Then
            SentenceArrived (inbuf2)
            inbuf2 = ""
        Else
            If inbuf1(Idx) = Asc("=") Then
                inbuf2 = inbuf2 & " "
            End If
            For i = 0 To WordLen - 1
                inbuf2 = inbuf2 & Chr(inbuf1(Idx + i))
            Next
        End If
        StartIdx = Idx + WordLen
    Loop
End Sub

that solve my problem,

and for good looking change this :
Code: Select all
Private Sub SendCommand(ByVal sCmd$)
.
.
.
End Sub

into this
Code: Select all
Private Sub SendCommand(ByVal sCmd$)
    Dim ar$(), i&, buf() As Byte
    Out Replace(sCmd, " ", vbCrLf )
    ar = Split(sCmd, " ")
    For i = 0 To UBound(ar)
        EncodeWord buf, ar(i)
    Next
    EncodeWord buf, ""
    If ws.State = sckConnected Then ws.SendData buf
End Sub


im working vb api to create and generate hotspot user, because with user manager maximal active session for lvl4 is 20, its better to use /ip/hotspot than /tool/user-manager, hotspot active user can up to 200,

wait for my next reply with full VB code for create user, im sory for my bad english, this is my firts post :D

amongdota
just joined
 
Posts: 2
Joined: Thu Aug 22, 2013 11:51 am

Re: API in Visual Basic 6 working fine!

by amongdota » Thu Aug 22, 2013 12:53 pm

ax045Y wrote:
thanks..
anyway i have new problem.
what command to enable user?
hmm,,
so this api just can do 1 line command?

no u can change a line white space, and read about api query here http://wiki.mikrotik.com/wiki/API#Query_word

drprotic
just joined
 
Posts: 2
Joined: Sat Feb 22, 2014 5:03 pm

Re: API in Visual Basic 6 working fine!

by drprotic » Sat Feb 22, 2014 5:05 pm

ax045Y wrote:

thanks..
anyway i have new problem.
what command to enable user?
hmm,,
so this api just can do 1 line command?

no u can change a line white space, and read about api query here http://wiki.mikrotik.com/wiki/API#Query_word



Its work

/ip/hotspot/user/add O =name=user1 O =password=111 O =limit-uptime=00:01:00

drprotic
just joined
 
Posts: 2
Joined: Sat Feb 22, 2014 5:03 pm

Re: API in Visual Basic 6 working fine!

by drprotic » Sun Feb 23, 2014 12:10 am

amongdota wrote:
ax045Y wrote:
thanks..
anyway i have new problem.
what command to enable user?
hmm,,
so this api just can do 1 line command?

no u can change a line white space, and read about api query here http://wiki.mikrotik.com/wiki/API#Query_word




Try this:
/ip/hotspot/user/add O =name=user1 O =password=111 O =limit-uptime=00:01:00

edilsonlsouza
just joined
 
Posts: 5
Joined: Tue Aug 05, 2014 8:03 pm

Re: API in Visual Basic 6 working fine!

by edilsonlsouza » Tue Aug 05, 2014 8:05 pm

Olá,

Using this program, which the command to remove a joined via IP and also how to add?

edilsonlsouza
just joined
 
Posts: 5
Joined: Tue Aug 05, 2014 8:03 pm

Re: API in Visual Basic 6 working fine!

by edilsonlsouza » Tue Aug 05, 2014 8:18 pm

Olá,

Using this program, which the command to remove a joined via IP and also how to add?

Obrigado!

edilsonlsouza
just joined
 
Posts: 5
Joined: Tue Aug 05, 2014 8:03 pm

Re: API in Visual Basic 6 working fine!

by edilsonlsouza » Wed Aug 06, 2014 4:26 pm

Olá,

Being ocorreno this error on the line below:

erro.png
erro.png (38.23 KiB) Viewed 1239 times


erro2.png
erro2.png (21.52 KiB) Viewed 1239 times


Thanks in advance!

edilsonlsouza
just joined
 
Posts: 5
Joined: Tue Aug 05, 2014 8:03 pm

Re: API in Visual Basic 6 working fine!

by edilsonlsouza » Wed Aug 06, 2014 4:52 pm

edilsonlsouza wrote:Olá,

Being ocorreno this error on the line below:

erro.png


erro2.png


Thanks in advance!


I solved the problem:

Open your project.
Click the Project menu item, then select References...
From Available References, check the box next to Microsoft VBScript Regular Expressions 5.5, where n.n is one of the following:

Obrigado!!!

edilsonlsouza
just joined
 
Posts: 5
Joined: Tue Aug 05, 2014 8:03 pm

Re: API in Visual Basic 6 working fine!

by edilsonlsouza » Wed Aug 06, 2014 5:04 pm

I'm new and I'm learning with this API. Wanted to know what command to add, modify and remove a user on mikrotik.

Thank you!

My examples via SSH/New Terminal:

modify
Code: Select all
/ip hotspot user set [/ip hotspot user find name=celular] profile=Debito

remove
Code: Select all
/ip hotspot user remove [/ip hotspot user find address=200.189.23.202]

register / add
Code: Select all
/ip hotspot user
add server=hotspot name=celular password=celular address=200.189.23.202 \
mac-address=bc:85:1f:d6:ac:3e profile=1024k disabled=no comment="EDILSON SOUZA - CELULAR, 3371-5090"


How is the command via API?

This system registers over a command line?

Thank you!

23 posts   •   Page 1 of 1

Who is online

Users browsing this forum: Yahoo [Bot] and 53 guests

It is currently Wed Nov 26, 2014 9:15 am