▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓
https://www.tim-international.net/
This is a lightweight proof of concept of how to setup a web server serving a Restful Web API using PHP for your data stored in Visma Administration.
Note: This concept or any of the instructions for setting it up do not encourage you to make any changes to the database.
Disclaimer: This contribution is provided without support or guarantees and should be used at your own risk. Do not underestimate the harm that can be done by gaining accessing to your Visma installation and data.
For this example we will place this project in C:\VismaAPI\
.
-
Download this repository from the link https://github.com/timint/visma-api/archive/refs/heads/main.zip and extract it to
C:\VismaAPI\
. -
Download ZIP archive of PHP for Windows from https://windows.php.net/. For this example we are using
VS16 x64 Thread Safe
.
Example: https://windows.php.net/downloads/releases/php-8.1.10-Win32-vs16-x64.zip
Extract the contents to the directory C:\VismaAPI\php\
.
- Download the Microsoft SQL Server Drivers for PHP. Make sure it's the corresponding version of your Visma installation, e.g.
SQL Server 2017
.
- SQL Server 2016: https://docs.microsoft.com/en-us/sql/connect/php/download-drivers-php-sql-server?view=sql-server-2016
- SQL Server 2017: https://docs.microsoft.com/en-us/sql/connect/php/download-drivers-php-sql-server?view=sql-server-2017
- SQL Server 2019: https://docs.microsoft.com/en-us/sql/connect/php/download-drivers-php-sql-server?view=sql-server-ver15
The downloaded executable file will let you extract the contents to a temporary destination. For this example we are using C:\Users\Me\Downloads\SQLSRV\
-
Copy the following file:
C:\Users\Me\Downloads\SQLSRV\php_sqlsrv_80_ts_x64.dll => C:\VismaAPI\php\ext\php_sqlsrv.dll
(You may now safely delete the temporary folder C:\Users\Me\Downloads\SQLSRV)
- Open settings.ini and edit the database name and secret key.
secret_key = 0123456789abcdef0123456789abcdef ; Make this one up
sql.database = SPCS_Adm_Ovnbol1000 ; The Visma database name for your company profile
-
Start the webserver by executing
C:\VismaAPI\start.cmd
-
Try accessing the web API with your web browser. Authentication is not required for localhost.
- GET https://127.0.0.1:8668/invoices
- GET https://127.0.0.1:8668/invoices?page=2
- GET https://127.0.0.1:8668/invoices/123456
Accessing the API from an external email address. Send the HTTP Authentication header along with the secret key:
Authentication: 0123456789abcdef0123456789abcdef
- To allow external requests over the web you need to make sure the HTTP TCP port is accessable from the web. This usually means it has to be permitted in firewalls.
Execute the file start.cmd
.
Edit api.php
with your favourite editor.
-
Make sure the server is not running.
-
Edit
C:\VismaAPI\settings.ini
with your favourite text editor. Change 8668 to something else. -
Now start again by executing
start.cmd
.
-
Download NSSM and place the nssm.exe executable in the folder
C:\VismaAPI\
. -
Execute
service_install.cmd
.
Your service can now be maintained in Windows Service Manager. Go to Windows Start Menu and type services
to access the Service Manager.
For instance you can configure the Windows Service to start automatically upon computer reboot.
You can use HeidiSQL to confirm that the SQL server is accessable and to inspect the database tables. To do so, download and install HeidiSQL. Try connecting with the following details:
Network Type: Microsoft SQL Server (Named pipe)
Library: MSOLEDBSQL
Hostname / IP: localhost\VISMA
[x] Use Windows Authentication
When successfully connected make note of the database name.
-
Click Start and type ODBC. Open "Data Sources (ODBC)".
-
Under the tab "User DSN" click the button "Add".
-
Select "ODBC Driver 11 for Microsoft SQL" and click the button "Complete".
-
Specifically give the new Data Source the following configuration, aside from what is already predefined:
Name: Visma API Server: localhost\VISMA
Click the button "Next"
[x] Use Integrated Windows Authentication
Application Intent: READONLY
Try updating your ODBC drivers to the very latest: