1

The process of adding a user to the device does not work in Laravel Those who can help provide the solution from the beginning of the process

this is my code...

      
      use maliklibs\Zkteco\Lib\ZKTeco;   
      $zk = new ZKTeco('192.168.100.222',4370);
      $zk->connect();
      $zk->enableDevice();
      $zk->setUser(1, '211', 'Carl', '5555', Util::LEVEL_USER, '0007909321');
      $zk->disableDevice();

This is the package that I use https://github.com/sketchtechnologies1/zkteco/tree/main

F Rowe
  • 2,042
  • 1
  • 11
  • 12

2 Answers2

0

First check if connection is OK, use ineger in the number arguments. Don't try 1 as unique ID, It's maybe admin or something try 10.

Note: Read the docs

You have to call disableDevice() before read/write any info of Device.

You have to call enableDevice() after read/write any info of Device.

So he working code should be:

$result = $err = "";
if($err = $zk->connect()){
    echo "OK Connect\n";
    $zk->disableDevice();
    echo "OK Enable\n";
    $result = $zk->setUser(10, 211, 'Carl', '5555', Util::LEVEL_USER, '0007909321');
    $zk->enableDevice();
} else {
    echo "Connect Error: $err\n"
}
var_dump($result); // to check if there is an error
Alijvhr
  • 1,695
  • 1
  • 3
  • 22
0

This could help:

$zk = new ZKTeco('192.168.100.222', 4370);
$zk->connect();
$zk->enableDevice();

$user_id = 1;
$user_name = 'Carl';
$password = '5555';
$level = Util::LEVEL_USER;
$card_number = '0007909321';

$result = $zk->setUser($user_id, '', $user_name, $password, $level, $card_number);
if ($result) {
    echo 'User added successfully';
} else {
    echo 'Failed to add user';
}

$zk->disableDevice();

$zk->disconnect();
Jeyhun Rashidov
  • 181
  • 3
  • 14