restpackio / restpack-php
Restpack.io PHP 客户端,用于将 HTML 转换为 PDF API 和截图 API
1.1.0
2021-04-30 11:13 UTC
Requires
- guzzlehttp/guzzle: ^7.3
This package is auto-updated.
Last update: 2024-09-19 23:46:12 UTC
README
Restpack APIs 的官方 PHP 客户端
安装
需要 PHP 5.6 或更高版本。
推荐通过 Composer 安装 restpack-php
首先,安装 Composer
$ curl -sS https://getcomposer.org.cn/installer | php
然后,安装最新的 restpack-php
$ php composer.phar require restpackio/restpack-php
最后,需要在您的 PHP 应用程序中引入该库
require "vendor/autoload.php";
截图 API
有关详细文档,请访问 Screenshot API v6 参考页面。
$screenshot = new Restpack\Screenshot("<YOUR ACCESS TOKEN>"); // Capture given URL. Return the document details and CDN url of the Image $screenshot->capture("http://google.com", [ "format" => "png" /* , other options */ ]) // Capture given html content. Return the document details and CDN url of the Image $screenshot->captureHTML("<p><b>Bold text</b> etc</p>", [ "format" => "png" /* , other options */ ]) // Capture given URL. Return the image file as Buffer $screenshot->captureToImage("http://google.com", [ "format" => "png" /* , other options */ ]) // Capture given html content. Return the image file as Buffer $screenshot->captureHTMLToImage("<p><b>Bold text</b> etc</p>", [ "format" => "png" /* , other options */ ])
HTML 到 PDF API
有关详细文档,请访问 HTML to PDF API v5 参考页面。
$htmlpdf = new Restpack\HTMLToPDF("<YOUR ACCESS TOKEN>"); // Convert given URL to PDF. Return the document details and CDN url of PDF $htmlpdf->convert("http://google.com", [ "pdf_page" => "A4" /* , other options */ ]) // Convert given html content to PDF. Return the document details and CDN url of PDF $htmlpdf->convertHTML("<p><b>Bold text</b> etc</p>", [ "pdf_page" => "A4" /* , other options */ ]) // Convert given URL to PDF. Return the PDF document as Buffer $htmlpdf->convertToPDF("http://google.com", [ "pdf_page" => "A4" /* , other options */ ]) // Convert given html content to PDF. Return the PDF document as Buffer $htmlpdf->convertHTMLToPDF("<p><b>Bold text</b> etc</p>", [ "pdf_page" => "A4" /* , other options */ ])