Platforms to show: All Mac Windows Linux Cross-Platform
/FMAPI/FileMaker Admin API Test
Required plugins for this example: MBS FMAPI Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /FMAPI/FileMaker Admin API Test
This example is the version from Sun, 29th Aug 2020.
Project "FileMaker Admin API Test.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open()
Dim l As New LoginWindow
l.show
End EventHandler
End Class
Class MainWindow Inherits Window
Control GetServerStatusButton Inherits PushButton
ControlInstance GetServerStatusButton Inherits PushButton
EventHandler Sub Action()
response = connection.GetServerStatus
UpdateResponse
End EventHandler
End Control
Control ResultTextArea Inherits TextArea
ControlInstance ResultTextArea Inherits TextArea
End Control
Control DebugTextArea Inherits TextArea
ControlInstance DebugTextArea Inherits TextArea
End Control
Control ResultField Inherits TextField
ControlInstance ResultField Inherits TextField
End Control
Control ListDatabasesButton Inherits PushButton
ControlInstance ListDatabasesButton Inherits PushButton
EventHandler Sub Action()
response = connection.ListDatabases
UpdateResponse
End EventHandler
End Control
Control ListSchedulesButton Inherits PushButton
ControlInstance ListSchedulesButton Inherits PushButton
EventHandler Sub Action()
response = connection.ListSchedules
UpdateResponse
End EventHandler
End Control
Control ListClientsButton Inherits PushButton
ControlInstance ListClientsButton Inherits PushButton
EventHandler Sub Action()
response = connection.ListClients
UpdateResponse
End EventHandler
End Control
Control GetServerGeneralSettingsButton Inherits PushButton
ControlInstance GetServerGeneralSettingsButton Inherits PushButton
EventHandler Sub Action()
response = connection.GetServerGeneralSettings
UpdateResponse
End EventHandler
End Control
Control GetServerGeneralSecurityButton Inherits PushButton
ControlInstance GetServerGeneralSecurityButton Inherits PushButton
EventHandler Sub Action()
response = connection.GetServerSecuritySetting
UpdateResponse
End EventHandler
End Control
Control GetPHPSettingsButton Inherits PushButton
ControlInstance GetPHPSettingsButton Inherits PushButton
EventHandler Sub Action()
response = connection.GetPHPSettings
UpdateResponse
End EventHandler
End Control
Control GetXMLSettingsButton Inherits PushButton
ControlInstance GetXMLSettingsButton Inherits PushButton
EventHandler Sub Action()
response = connection.GetXMLSettings
UpdateResponse
End EventHandler
End Control
Control GetXDBCSettingsButton Inherits PushButton
ControlInstance GetXDBCSettingsButton Inherits PushButton
EventHandler Sub Action()
response = connection.GetXDBCSettings
UpdateResponse
End EventHandler
End Control
Control GetDataAPISettingsButton Inherits PushButton
ControlInstance GetDataAPISettingsButton Inherits PushButton
EventHandler Sub Action()
response = connection.GetDataAPISettings
UpdateResponse
End EventHandler
End Control
Control GetWPESettingsButton Inherits PushButton
ControlInstance GetWPESettingsButton Inherits PushButton
EventHandler Sub Action()
response = connection.GetWPESettings
UpdateResponse
End EventHandler
End Control
Control GetWebDirectSettingsButton Inherits PushButton
ControlInstance GetWebDirectSettingsButton Inherits PushButton
EventHandler Sub Action()
response = connection.GetWebDirectSettings
UpdateResponse
End EventHandler
End Control
Sub UpdateResponse()
If response = Nil Then
ResultField.Text = "No response!"
DebugTextArea.Text = ""
ResultTextArea.Text = ""
Else
ResultField.Text = Str(response.ErrorCode)+" "+response.ErrorMessage
Dim Debug As String = response.DebugMessages
If response.ErrorCode <> 0 Then
Debug = Debug + EndOfLine + EndOfLine + response.RawResultJSON
End If
DebugTextArea.Text = ReplaceLineEndings(Debug, EndOfLine)
ResultTextArea.Text = ReplaceLineEndings(response.ResultJSON, EndOfLine)
End If
End Sub
Property connection As FMAdminMBS
Property response As FMResponseMBS
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class LoginWindow Inherits Window
Control ServerField Inherits TextField
ControlInstance ServerField Inherits TextField
End Control
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
Control UserNameField Inherits TextField
ControlInstance UserNameField Inherits TextField
End Control
Control Label2 Inherits Label
ControlInstance Label2 Inherits Label
End Control
Control PasswordField Inherits TextField
ControlInstance PasswordField Inherits TextField
End Control
Control Label3 Inherits Label
ControlInstance Label3 Inherits Label
End Control
Control LoginButton Inherits PushButton
ControlInstance LoginButton Inherits PushButton
EventHandler Sub Action()
// new connection to FileMaker Server
Dim d As New FMAdminMBS
'd.Version = "v2" // default is v2
d.Password = PasswordField.Text.Trim
d.Username = UserNameField.Text.Trim
d.Server = ServerField.Text.trim
// optional headers
d.Headers.Value("User-Agent") = "FileMaker Admin API Test 1.0"
Dim r As FMResponseMBS = d.Login
If r = Nil Then
Break
Return
End If
// connection worked?
If r.CURLErrorCode <> 0 Then
ShowLog r
MsgBox r.CURLErrorMessage
End If
Select Case r.ResponseCode
Case 200
Dim m As New MainWindow
m.connection = d
m.response = r
m.UpdateResponse
Self.close
Case 401
ShowLog r
MsgBox "Invalid credentials."
Else
ShowLog r
MsgBox "ResponseCode: "+Str(r.ResponseCode)
End Select
End EventHandler
End Control
Control CancelButton Inherits PushButton
ControlInstance CancelButton Inherits PushButton
EventHandler Sub Action()
Quit
End EventHandler
End Control
Control TextLog Inherits TextArea
ControlInstance TextLog Inherits TextArea
End Control
EventHandler Sub Open()
Self.Height = 200
End EventHandler
Sub ShowLog(r as FMResponseMBS)
Self.Height = 400
textlog.Text = ReplaceLineEndings(r.DebugMessages, EndOfLine)
TextLog.Visible = True
End Sub
End Class
End Project
See also:
The items on this page are in the following plugins: MBS FMAPI Plugin.