wnx/screeenly-client

该软件包已被弃用,不再维护。未建议替代软件包。

screeenly.com 的 PHP API 包装器

v2.0.2 2018-04-06 16:16 UTC

This package is auto-updated.

Last update: 2022-02-01 12:43:37 UTC


README

Build Status
Latest Stable Version Total Downloads Latest Unstable Version License

PHP 包装器用于 Screeenly API。您必须拥有 Screeenly 账户才能使用此软件包。

重要通知: 该软件包已被弃用!我希望专注于更有用的项目,而 screeenly API 已经非常 易于使用

安装

使用 composer 安装软件包

Guzzle v6

$ composer require "wnx/screeenly-client:~2.0"

Guzzle v5

$ composer require "wnx/screeenly-client:~1.0"

对于 Laravel 4 项目

$ composer require "wnx/screeenly-client:~0.3"

使用

Laravel 5

了解更多关于 Laravel 4 的使用方法

将以下代码添加到 app/conifg/app.php 中的 providers 数组

...

'Wnx\ScreeenlyClient\ScreeenlyClientServiceProvider',

发布配置文件,并在 config/screeenly_client.php 中添加您的 Screeenly API 密钥。

php artisan vendor:publish --provider="Wnx\ScreeenlyClient\ScreeenlyClientServiceProvider"

现在您可以使用截图外观。如下所示使用它

$path       = public_path('/');
$screenshot = Screenshot::capture('http://google.com');
$localPath  = $screenshot->store($path, 'screenshot.jpg');

非 Laravel 使用

use Wnx\ScreeenlyClient\Screenshot;
...

$screenshot = new Screenshot($key);
$screenshot->capture('http://google.com');
$localPath = $screenshot->store('path/to/image/store/', 'screenshot.jpg');

可用方法

$screeenshot->capture($url);

创建给定 URL 的截图。

$screeenshot->store($path, $filename);

将截图存储在本地磁盘上。返回图像路径。

$screeenshot->setHeight(integer);

可选。设置截图高度。

$screeenshot->setWidth(integer);

可选。设置截图宽度。

$screeenshot->getPath();

返回 Screeenly 服务器上临时图像的路径。

$screeenshot->getBase64();

返回截图的 base64 字符串。

许可证

MIT