printermonk / printermonk-php
为您的打印机提供API的PrinterMonk PHP客户端
v0.1.0
2017-02-07 14:18 UTC
Requires
- php: >=5.6
This package is not auto-updated.
Last update: 2024-09-23 15:13:32 UTC
README
这是一个开源的PrinterMonk API PHP客户端
安装
使用 composer 获取
composer require printermonk/printermonk-php
示例:获取所有打印机
<?php use PrinterMonk\PrinterMonkClient; use PrinterMonk\Repositories\PrinterRepository; require __DIR__ . '/vendor/autoload.php'; $apiKey = getenv('PRINTERMONK_API_KEY'); // Your PrinterMonk API key $client = new PrinterMonkClient($apiKey); $printers = PrinterRepository::all($client); var_dump($printers);
示例:获取单个打印机
<?php use PrinterMonk\PrinterMonkClient; use PrinterMonk\Repositories\PrinterRepository; require __DIR__ . '/vendor/autoload.php'; $apiKey = getenv('PRINTERMONK_API_KEY'); // Your PrinterMonk API key $printerId = 'prtr_uniqueprinterkey'; $client = new PrinterMonkClient($apiKey); $printer = PrinterRepository::find($printerId, $client); var_dump($printer);
示例:向PrinterMonk发送新的打印作业
<?php use PrinterMonk\Entities\PrintJob; use PrinterMonk\PrinterMonkClient; require __DIR__ . '/vendor/autoload.php'; $apiKey = getenv('PRINTERMONK_API_KEY'); // Your PrinterMonk API key $printerId = 'prtr_uniqueprinterkey'; $client = new PrinterMonkClient($apiKey); $printJob = new PrintJob(); $printJob->printerId = $printerId; $printJob->name = 'Example document'; $printJob->contentType = 'pdf'; $printJob->content = base64_encode(file_get_contents('example.pdf')); $printJob->post($client);