solwee / pixt-api
Pix.T API
0.1.1
2024-01-02 10:36 UTC
Requires
- php: >=8.2
- guzzlehttp/guzzle: ^7.8
Requires (Dev)
- phpunit/phpunit: ^10.5
This package is not auto-updated.
Last update: 2024-09-24 14:11:19 UTC
README
概览
本项目的目标是开发一个简单的PHP客户端,用于PixT API。PixT技术为图像创作者提供了一个简单的方法来认证他们的图像,从而提高其可信度。
安装
要安装solwee/pixt-api的最新版本,请使用Composer。
文档
ClientInterface
被设计用来处理与图像处理和检索相关的操作。它包括生成用于上传图像的预签名URL、将这些数据上传到这些URL以及检索图像证书的方法。
方法
getPresignedURL
- 描述:生成用于上传图像的预签名URL。
- 参数:
$imageFileName
(string
):要生成预签名URL的图像文件名。
- 返回:
PresignedUrl
- 代表预签名URL的对象。
putToPresignedURL
- 描述:将数据上传到指定的预签名URL。
- 参数:
$presignedUrl
(PresignedUrl
):要上传数据的预签名URL。$data
(string
):要上传的数据,通常是图像文件的内容。
- 返回:
int
- 表示上传操作结果的HTTP状态码。
getImageCertificate
- 描述:检索指定图像的证书。
- 参数:
$imageId
(string
):图像的唯一标识符。$keywords
(bool
,可选):一个标志,用于在证书中包含关键词。默认为false
。
- 返回:
ImageCertificate
- 包含图像证书详细信息的对象。
使用示例
$client = new Solwee\Pixt\Client( new \GuzzleHttp\Client(), "https://partner.pixt.42cloud.io", "<super secret token>", ); // Get a presigned URL for an image upload $presignedUrl = $client->getPresignedURL("example.jpg"); // Upload image data to the presigned URL $imageData = file_get_contents("example.jpg"); $status = $client->putToPresignedURL($presignedUrl, $imageData); // Retrieve the certificate for the image $imageCertificate = $client->getImageCertificate("image123", true);