Follow the steps below to configure and deploy the integration for a new client.
biometric_punches table in the client's MSSQL database.timeoffice_state.json so each run only pulls new data.Open timeoffice-api.php and update the values inside the Config block at the top of the file.
$corporateId = "corporateId"; // Client's Corporate ID from TimeOffice $username = "username"; // API username provided by TimeOffice $password = "password"; // API password provided by TimeOffice
$serverName = 'localhost'; // MSSQL server hostname or IP $uid = ''; // Database username $pwd = ''; // Database password $databaseName = ''; // Target database name
sqlsrv PHP driver.Ensure the biometric_punches table exists in the target database with at least the following columns:
| Column | Type | Notes |
|---|---|---|
emp_code | VARCHAR | Employee code from TimeOffice |
log_date | DATE | Date portion of the punch (YYYY-MM-DD) |
punch_time | TIME | Time portion of the punch (HH:MM:SS) |
device_serial_number | VARCHAR | Hardcoded as TIMEOFFICE001 |
device_name | VARCHAR | Hardcoded as TimeOffice |
log_date_time | DATETIME | Full punch timestamp |
created_date | DATETIME | Row insertion timestamp |
Copy the integration files into your Apache web root. The script needs to be accessible via a URL so the cron job can trigger it using wget.
On the same server as Apache, run:
cp -r /source/path/biometric-timeoffice /var/www/html/biometric-timeoffice
If deploying from a remote machine, use scp:
scp -r ./biometric-timeoffice user@your-server-ip:/var/www/html/biometric-timeoffice
The script writes timeoffice_state.json to its own directory. Apache's user (usually www-data) must have write permission on that folder:
# Give Apache write access to the folder
chown -R www-data:www-data /var/www/html/biometric-timeoffice
chmod -R 755 /var/www/html/biometric-timeoffice
Open a browser or run the following to confirm Apache serves the script correctly:
curl -I http://your-domain.com/biometric-timeoffice/timeoffice-api.php
You should receive an HTTP/1.1 200 OK response. If you get a 403 or 404, check the folder path and Apache permissions.
Open the crontab editor on the server:
crontab -e
Since the script is hosted on Apache, use wget to hit the URL every 5 minutes:
*/5 * * * * wget -q -O /var/log/timeoffice.log http://your-domain.com/biometric-timeoffice/timeoffice-api.php 2>&1
your-domain.com with your actual domain or server IP.
If you prefer not to use a public URL, you can still trigger it directly via PHP CLI:
*/5 * * * * php /var/www/html/biometric-timeoffice/timeoffice-api.php >> /var/log/timeoffice.log 2>&1
wget method is preferred when running on Apache as it goes through the same execution environment as a normal web request.
On the first run there is no state file yet. The script will default to pulling from the start of the current month. Trigger it manually once to verify everything is working:
wget -q -O - http://your-domain.com/biometric-timeoffice/timeoffice-api.php
Expected output on success:
api.etimeoffice.com
The file timeoffice_state.json is created automatically after the first successful run in the same directory as the script. It looks like:
{
"last_record": "032026$489"
}
last_record manually using the format MMYYYY$LastID — for example, 012026$1 to re-pull from January 2026.
$corporateId, $username, $password from the client's TimeOffice account$serverName, $uid, $pwd, $databaseName for the client's MSSQL databasebiometric_punches table exists with the correct columns/var/www/html/biometric-timeoffice/ on the Apache serverchown / chmod)wget and confirm records are insertedwget entry