cloudlayerio / cloudlayerio-php
cloudlayer.io API 库,使用 PHP 轻松访问我们的基于 REST 的 API 服务。
1.03
2020-11-25 18:38 UTC
Requires
- ext-json: *
- guzzlehttp/guzzle: ^7.2
Requires (Dev)
- mikey179/vfsstream: ^1.6
- phpunit/phpunit: ^9
- symfony/dotenv: ^5.1
README
cloudlayer.io API 库,使用 PHP 轻松访问我们的基于 REST 的 API 服务。
- 将 HTML 转换为 PDF 和图像
- 将网页转换为 PDF 和图像(使用任何公开 URL)
示例用法
- 加载 composer 依赖项
require __DIR__ ."/vendor/autoload.php";
- 使用 API 密钥配置客户端
use CloudLayerIO\Client as CloudLayer;
$apiKey = '<YOUR_API_KEY>';
CloudLayer::config([
'api_key' => $apiKey,
]);
- 将 URL 转换为图像或 PDF
$url = \CloudLayerIO\Resource\Url('http://exampl.com');
$image = $url->toImage(); // return object of \CloudLayerIO\Model\File
//save image file
$image->save('test.png');
$pdf = $url->toPdf(); // return object of \CloudLayerIO\Model\File
//save pdf file
$pdf->save('test.pdf');
- 将 HTML 转换为图像或 PDF
$html = \CloudLayerIO\Resource\Html('<html></html>');
$html->toImage(); // return object of \CloudLayerIO\Model\File
$html->toPdf(); // return object of \CloudLayerIO\Model\File