Getting APIs to work on ZM 1.28.x - 3esmit/zmNinja GitHub Wiki
Instructions to get APIs working on ZM 1.28.x, till a debian port is released
Note: zmNinja will work after you make these changes, but there are still some important changes (not related to APIs) in 1.29 that are not going to be there in your install. So I'm not going to be able to support you as far as zmNinja goes. Specifically, Android users, please make sure you enable the zmNinja option in Dev Settings that exits the app when switching to the background, or you are going to have a lot of data consumption in the background
This has been tested on a Debian 8 system with ZM installed using the "Easy Way" wiki instructions. Please make sure ZM is working properly before you attempt this
su - root
cd /usr/share/zoneminder/www
If you have an api directory there, rename it, if it doesn't exist don't worry
mv api api_old
mkdir api
Grab a copy of the API files modified to work with 1.28. I've modified some files so that it acts as 1.29 and does not check for some fields only available in 1.29. (It needs to act as 1.29 because zmNinja won't work if it detects 1.28)
cd api
wget https://raw.githubusercontent.com/pliablepixels/pliablepixels.github.io/master/downloads/api_files_1-28.zip
unzip api_files_1-28.zip
Fix permissions:
chown -R www-data:www-data *
Edit your zoneminder.conf - should be in /etc/apache2/conf-available/zoneminder.conf
Make sure this is in there. If not, add it to the end. This is important or your api path won't work
<Directory /usr/share/zoneminder/www/api>
AllowOverride All
</Directory>
enable rewrite module:
a2enmod rewrite
service apache2 restart
Very important: The API layer assumes the zm DB has a user of zmuser
and password of zmpass
. If you have changed this in your instance, edit app/Config/database.php
and around line 71, change the credentials.
open your browser and type in
http://serverip/zm/api
Do you see green? Good. Do you see red? Post here
Now try
http://serverip/zm/api/host/getVersion.json
See 1.29? Good. (Note it is just masquerading as 1.29 in the API layer to keep zmNinja happy. You are still running 1.28.x)
Note that if you have ZM_AUTH enabled, you need to login in another tab or APIs will fail with an unauthorized message.
Read the API validation docs for more tests.