PHP code example of bishwajitcadhikary / zkteco-sdk

1. Go to this page and download the library: Download bishwajitcadhikary/zkteco-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bishwajitcadhikary / zkteco-sdk example snippets


    use Rats\Zkteco\Lib\ZKTeco;

//  1 s't parameter is string $ip Device IP Address
//  2 nd  parameter is integer $port Default: 4370
  
    $zk = new ZKTeco('192.168.1.201');
    
//  or you can use with port
//    $zk = new ZKTeco('192.168.1.201', 8080);
    

//    connect
//    this return bool
    $zk->connect();   

//    disconnect
//    this return bool

    $zk->disconnect();   

//    enable
//    this return bool/mixed

    $zk->enableDevice();   

//    disable 
//    this return bool/mixed

    $zk->disableDevice(); 

//    get device version 
//    this return bool/mixed

    $zk->version(); 

//    get device os version 
//    this return bool/mixed

    $zk->osVersion(); 

//    turn off the device 
//    this return bool/mixed

    $zk->shutdown(); 

//    restart the device 
//    this return bool/mixed

    $zk->restart(); 

//    sleep the device 
//    this return bool/mixed

    $zk->sleep(); 

//    resume the device from sleep 
//    this return bool/mixed

    $zk->resume(); 

//    voice test of the device "Thank you" 
//    this return bool/mixed

    $zk->testVoice(); 

//    get platform 
//    this return bool/mixed

    $zk->platform(); 

//    get firmware version
//    this return bool/mixed

    $zk->fmVersion(); 

//    get work code
//    this return bool/mixed

    $zk->workCode(); 

//    get SSR
//    this return bool/mixed

    $zk->ssr(); 

//    get  Pin Width
//    this return bool/mixed

    $zk->pinWidth(); 

//    get device serial number
//    this return bool/mixed

    $zk->serialNumber(); 

//    get device name
//    this return bool/mixed

    $zk->deviceName(); 

//    get device time

//    return bool/mixed bool|mixed Format: "Y-m-d H:i:s"

    $zk->getTime(); 

//    set device time
//    parameter string $t Format: "Y-m-d H:i:s"
//    return bool/mixed

    $zk->setTime(); 

//    get User
//    this return array[]

    $zk->getUser(); 

//    set user

//    1 s't parameter int $uid Unique ID (max 65535)
//    2 nd parameter int|string $userid ID in DB (same like $uid, max length = 9, only numbers - depends device setting)
//    3 rd parameter string $name (max length = 24)
//    4 th parameter int|string $password (max length = 8, only numbers - depends device setting)
//    5 th parameter int $role Default Util::LEVEL_USER
//    6 th parameter int $cardno Default 0 (max length = 10, only numbers

//    return bool|mixed

    $zk->setUser(); 

//    remove all admin
//    return bool|mixed

    $zk->clearAdmin(); 

//    remove all users
//    return bool|mixed

    $zk->clearAdmin(); 

//    remove a user by $uid
//    parameter integer $uid
//    return bool|mixed

    $zk->removeUser(); 

//    get attendance log

//    return array[]

//    like as 0 => array:5 [▼
//              "uid" => 1      /* serial number of the attendance */
//              "id" => "1"     /* user id of the application */
//              "state" => 1    /* the authentication type, 1 for Fingerprint, 4 for RF Card etc */
//              "timestamp" => "2020-05-27 21:21:06" /* time of attendance */
//              "type" => 255   /* attendance type, like check-in, check-out, overtime-in, overtime-out, break-in & break-out etc. if attendance type is none of them, it gives  255. */
//              ]

    $zk->getAttendance(); 

//    clear attendance log

//    return bool/mixed

    $zk->clearAttendance();