承接 intellexapps/pixabay-api-client 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

intellexapps/pixabay-api-client

Composer 安装命令:

composer require intellexapps/pixabay-api-client

包简介

Lightweight PHP client for Pixabay API

README 文档

README

  • Support for the complete Pixabay API
  • Both image and video
  • Define search parameters using type-strict fluent setters
  • Utility class for downloading the results
  • No 3rd party libraries used

Disclaimer

During development there were some minor changes in the API: they removed "favorites" count from the response. However, this broke our code and made v1.x.x unusable.

BE ADVISED: Any changes on the side of Pixabay CAN render this library unusable at any point. For more info, see the Licence.

Usage

These are snippets from the files in the tests/examples directory.

Videos

// Invoke the API directly by passing an array for the search
$response = (new VideoApi(API_KEY))->fetch(new VideoSearchParams([
	'category'       => Category::TRANSPORTATION,
	'editors_choice' => true,
	'per_page'       => 3
]));

// Show images
foreach ($response->getVideos() as $video) {
	echo $video->getMediumVideo()->getUrl() . PHP_EOL;
}

Images

// Define search parameters using fluent setters
$search = (new ImageSearchParams())
	->setColors([ Color::GREEN, Color::ORANGE ])
	->setImageType(ImageType::PHOTO)
	->setCategory(Category::NATURE)
	->setEditorsChoice(true)
	->setPerPage(3);

// Invoke the API
$response = (new ImageApi(API_KEY))->fetch($search);

// Show images
foreach ($response->getImages() as $image) {
	echo $image->getURLForSize180() . PHP_EOL;
}

Download results

// Destination must be defined 
if ($argc < 2) {
	echo "Usage: php -f tests/examples/download.php <destination> <count>";
	exit(1);
}

// Read the input parameters
$count = (int) min(50, $argv[2] ?? 50);
$destination = rtrim($argv[1], DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
if (!is_dir($destination) || !is_writable($destination)) {
	echo "Supplied destination is not a writable directory: ${destination}";
	exit(2);
}

// Invoke the API
$response = (new ImageApi(API_KEY))->fetch(new ImageSearchParams([
	PixabayParam::Q              => 'kitten',
	PixabayParam::CATEGORY       => Category::ANIMALS,
	PixabayParam::IMAGE_TYPE     => ImageType::PHOTO,
	PixabayParam::ORIENTATION    => Orientation::HORIZONTAL,
	PixabayParam::PER_PAGE       => $count,
	PixabayParam::SAFE_SEARCH    => true,
	PixabayParam::EDITORS_CHOICE => true,
	PixabayParam::ORDER          => OrderAlias::POPULAR
]));

// Download and store
$images = $response->getImages();
$count = count($images);
foreach ($images as $i => $image) {
	$preview = explode('/', $image->getPreviewURL());
	$name = end($preview) . PHP_EOL;
	echo sprintf("%3s / %3s, %s", $i + 1, $count, $name);
	Downloader::downloadTo($image->getLargeImageURL(), "{$destination}/{$name}");
}

Run examples

In order to run examples the Pixabay API key needs to be defined.

PIXABAY_API_KEY=0000000-0000000000000000000000000 php -f tests/examples/images.php
PIXABAY_API_KEY=0000000-0000000000000000000000000 php -f tests/examples/videos.php
PIXABAY_API_KEY=0000000-0000000000000000000000000 php -f tests/examples/download.php ~/Desktop/ 5

References

Credits

Script has been written by the Intellex team.

intellexapps/pixabay-api-client 适用场景与选型建议

intellexapps/pixabay-api-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 12 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 intellexapps/pixabay-api-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 intellexapps/pixabay-api-client 我们能提供哪些服务?
定制开发 / 二次开发

基于 intellexapps/pixabay-api-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 11
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-12-17