1st of your command created coockies.txt and second command produced this output:
Code: Select all
{
"version": "1.28.102",
"apiversion": "1.28.102.1"
}
Code: Select all
{
"version": "1.28.102",
"apiversion": "1.28.102.1"
}
marcolino7 wrote:Hi Asker,
1st of your command created coockies.txt and second command produced this output:
Code: Select all
{ "version": "1.28.102", "apiversion": "1.28.102.1" }
Code: Select all
curl -c cookies.txt -d "username=xxxx&password=yyyy&action=login&view=console" http://yourZMIP/zm/index.php
Code: Select all
curl -b cookies.txt http://yourZMIP/zm/api/monitors.json
marcolino7 wrote:Hi asker,
thanks for help.
Now I still need your help, to configure my Home Automation software to access the API with Authentication.
I use curl to access the ZM API, now i need to add authentication.
How can I perform this? which curl command I should use?
Thanks
Make sure you specify a path for cookies.txt so you know where it is being created and its writablemarcolino7 wrote:Hi Asker,
I tried to create a cron job executed every 5 minutes, but cookies.txt was not created.
Do you have any suggestion?
Regards
Code: Select all
{
"success": false,
"data": {
"name": "Not Authenticated",
"message": "Not Authenticated",
"url": "\/zm\/api\/host\/getVersion.json",
"exception": {
"class": "NotFoundException",
"code": 404,
"message": "Not Authenticated",
"trace": [
"#0 [internal function]: AppController->beforeFilter(Object(CakeEvent))",
"#1 \/usr\/share\/zoneminder\/www\/api\/lib\/Cake\/Event\/CakeEventManager.php(244): call_user_func(Array, Object(CakeEvent))",
"#2 \/usr\/share\/zoneminder\/www\/api\/lib\/Cake\/Controller\/Controller.php(674): CakeEventManager->dispatch(Object(CakeEvent))",
"#3 \/usr\/share\/zoneminder\/www\/api\/lib\/Cake\/Routing\/Dispatcher.php(187): Controller->startupProcess()",
"#4 \/usr\/share\/zoneminder\/www\/api\/lib\/Cake\/Routing\/Dispatcher.php(165): Dispatcher->_invoke(Object(HostController), Object(CakeRequest))",
"#5 \/usr\/share\/zoneminder\/www\/api\/app\/webroot\/index.php(108): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))",
"#6 {main}"
]
},
"queryLog": {
"default": {
"log": [
{
"query": "SELECT `Config`.`Id`, `Config`.`Name`, `Config`.`Value`, `Config`.`Type`, `Config`.`DefaultValue`, `Config`.`Hint`, `Config`.`Pattern`, `Config`.`Format`, `Config`.`Prompt`, `Config`.`Help`, `Config`.`Category`, `Config`.`Readonly`, `Config`.`Requires` FROM `zm`.`Config` AS `Config` WHERE `Config`.`Name` = 'ZM_OPT_USE_AUTH' LIMIT 1",
"params": [],
"affected": 1,
"numRows": 1,
"took": 0
},
{
"query": "SELECT `Config`.`Id`, `Config`.`Name`, `Config`.`Value`, `Config`.`Type`, `Config`.`DefaultValue`, `Config`.`Hint`, `Config`.`Pattern`, `Config`.`Format`, `Config`.`Prompt`, `Config`.`Help`, `Config`.`Category`, `Config`.`Readonly`, `Config`.`Requires` FROM `zm`.`Config` AS `Config` WHERE `Config`.`Name` = 'ZM_OPT_USE_AUTH' LIMIT 1",
"params": [],
"affected": 1,
"numRows": 1,
"took": 0
}
],
"count": 2,
"time": 0
}
}
}
}
Code: Select all
Configure::write('Session', array(
'defaults' => 'php',
'cookie'=>'ZMSESSID'
));
marcolino7 wrote:Hi,
in browser now works, after authenticating with ZM, cake PHP is working and I can get API version.
I still have issue runnin API's call from curl
Marco