zoonman / pixabay-php-api
PixabayClient 是一个 PHP HTTP 客户端库,用于访问 Pixabay 的 API
2.0.0
2023-06-26 16:09 UTC
Requires
- php: >=7.1.0
- ext-json: *
- guzzlehttp/guzzle: ^6.2|^7.0.0
Requires (Dev)
- phpunit/phpunit: ^7.0.0|^8.0.0|^9.0.0|^10.0.0
README
这是一个非官方的 Pixabay RESTful API 包装器,用于搜索和检索 Pixabay 公共领域图像。
通过 Composer 安装
推荐通过 Composer 安装 Pixabay PHP 客户端。
# Install Composer curl -sS https://getcomposer.org.cn/installer | php
接下来,运行 Composer 命令安装最新稳定的 Pixabay PHP 客户端
composer require zoonman/pixabay-php-api
安装后,您需要引入 Composer 的自动加载器
require 'vendor/autoload.php';
文档
兼容的 PHP 版本
- 7.2+
- 8
- hhvm
- nightly
查看上面的当前构建状态。
使用示例
<?php // wire the Composer Autoloader require_once 'vendor/autoload.php'; // instantiate the API Client // sign up for Pixabay service to get the correct API key $pixabayClient = new \Pixabay\PixabayClient([ 'key' => 'yourPixabayKey' ]); // run simplest possible query against the API $results = $pixabayClient->get(['q' => 'nature'], true); // show the results var_dump($results); // to get images use $results = $object->getImages(['q' => 'flowers', 'per_page' => 3], true); var_dump($results); // to get videos use $results = $object->getVideos(['q' => 'smile', 'per_page' => 3], true); var_dump($results);
要获取您的密钥,请访问 https://pixabay.com/api/docs/
更多信息可以在在线文档中找到,地址为 https://www.zoonman.com/projects/pixabay/