PHP code example of khicks / myq-php

1. Go to this page and download the library: Download khicks/myq-php 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/ */

    

khicks / myq-php example snippets




= new MyQ\MyQ($myq_username, $myq_password);
$door = $myq->getGarageDoorDevices()[0];

// Get door state information.
$door->getState()->getDescription();
// "closed"
$door->getState()->getDeltaInt();
// 4924
$door->getState()->getDeltaStr();
// "1 hour, 22 minutes, 4 seconds"

// Open and close door.
$door->open();
sleep(20);
$door->close();

// The security token is like a cookie that you obtain after logging in.
// You should save this value if you want to use it for subsequent runs.
$myq->getSecurityToken()->getValue();
// "5ff81c31-6725-40f5-81a2-dc352ad300dd"



= new MyQ\MyQ($myq_username, $myq_password, $security_token);
$door = $myq->getGarageDoorDevices()[0];
// ...
bash
$ sudo apt-get install composer php php-curl
$ composer