PHP code example of aso824 / octoprint-php-api
1. Go to this page and download the library: Download aso824/octoprint-php-api 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/ */
aso824 / octoprint-php-api example snippets
use Http\Discovery\HttpClientDiscovery;
use aso824\OctoPrintPHP\Client;
use aso824\OctoPrintPHP\Configuration;
$httpClient = HttpClientDiscovery::find();
$configuration = new Configuration('http://octoprint.local', 'your-api-key');
$octoClient = new Client($configuration, $httpClient);
var_dump($octoClient->getVersion()->getServer()); // "1.4.2"
$file = $octoClient->files->getFile('test.gcode');
var_dump($file->getGcodeAnalysis()->getEstimatedPrintTime()); // 10120 (seconds)