zkteco
zkteco copied to clipboard
unpack(): Type H: not enough input, need 1, have 0
I got This Error when I Try to call getUser():
unpack(): Type H: not enough input, need 1, have 0
same issue here.. how do you fix it?
same issue with me .. did you fix it ??
I'm also having the same issue. anyone found the solution or have any idea ?
you should call $zk->connect(); before call $zk->getUser(); like this
$zk = new ZKTeco(your device ip);
$zk->connect();
$users = $zk->getUser();
dd($users);
Make sure you can ping and telnet to your device first, most of the time is because the device is not connected yet.
ping YOUR-IP telnet YOUR-IP 4370
any selution ?
I think this is more of a usage/documentation error, not a functionality issue.
It appears that the library does not internally store whether or not the connect() call was successful. (and FYI, the timeout is set to 60 seconds before it will give up) It leaves it up to you to verify it.
To catch this condition, check the result of the connect() call in your code, to prevent any operations like "getUser" or "getAttendance" unless the connect() method returned true:
$zk = new \Rats\Zkteco\Lib\ZKTeco( <ip_addr> );
if (!$zk->connect()) {
print "Couldn't connect!";
exit;
} else {
print "Connected.";
}
// connection verified .. continue on with program
$zk->getAttendance();