skip to Main Content

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 maliklibsZktecoLibZKTeco;   
      $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

2

Answers


  1. 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 Connectn";
        $zk->disableDevice();
        echo "OK Enablen";
        $result = $zk->setUser(10, 211, 'Carl', '5555', Util::LEVEL_USER, '0007909321');
        $zk->enableDevice();
    } else {
        echo "Connect Error: $errn"
    }
    var_dump($result); // to check if there is an error
    
    Login or Signup to reply.
  2. 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();
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search