devscast/pexels
Composer 安装命令:
composer require devscast/pexels
包简介
PHP client for https://pexels.com
关键字:
README 文档
README
The Pexels API enables programmatic access to the full Pexels content library, including photos, videos. All content is available free of charge, and you are welcome to use Pexels content for anything you'd like, as long as it is within our Guidelines.
Guidelines
Whenever you are doing an API request make sure to show a prominent link to Pexels. You can use a text link (e.g. "Photos provided by Pexels") or a link with our logo.
Always credit our photographers when possible (e.g. "Photo by John Doe on Pexels" with a link to the photo page on Pexels).
You may not copy or replicate core functionality of Pexels (including making Pexels content available as a wallpaper app).
Do not abuse the API. By default, the API is rate-limited to 200 requests per hour and 20,000 requests per month. You may contact us to request a higher limit, but please include examples, or be prepared to give a demo, that clearly shows your use of the API with attribution. If you meet our API terms, you can get unlimited requests for free.
Abuse of the Pexels API, including but not limited to attempting to work around the rate limit, will lead to termination of your API access.
Authorization
Authorization is required for the Pexels API. Anyone with a Pexels account can request an API key, which you will receive instantly.
Install
composer require devscast/pexels
Usage
Create an instance of the Pexels API Client by passing in your API token as parameter.
// ... use Devscast\Pexels\Client; // ... $pexels = new Client(token: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx');
Search for photos
This endpoint enables you to search Pexels for any topic that you would like. For example your query could be something broad like Nature, Tigers, People. Or it could be something specific like Group of people working.
$photos = $pexels->searchPhotos('Tigers'); // landscape photos only $photos = $pexels->searchPhotos('Tigers', new SearchParameters(orientation: 'landscape', page: 2))
Curated photos
This endpoint enables you to receive real-time photos curated by the Pexels team.
We add at least one new photo per hour to our curated list so that you always get a changing selection of trending photos.
$photos = $pexels->curatedPhotos(); // paginated $photos = $pexels->curatedPhotos(new PaginationParameters(page: 2, per_page: 60));
Get a photo
Retrieve a specific Photo from its id.
$photo = $pexels->photo(id: 11762029);
Search for videos
This endpoint enables you to search Pexels for any topic that you would like. For example your query could be something broad like Nature, Tigers, People. Or it could be something specific like Group of people working.
$videos = $pexels->searchVideos('Tigers'); // landscape videos only $videos = $pexels->searchVideos('Tigers', new SearchParameters(orientation: 'landscape', page: 2))
Popular Videos
This endpoint enables you to receive the current popular Pexels videos.
$videos = $pexels->popularVideos(); // 30 secondes popular videos $videos = $pexels->popularVideos(new PopularVideosParameters(min_duration: 30, max_duration: 30));
Get a video
Retrieve a specific Video from its id.
$video = $pexels->video(id: 12593410);
Featured Collections
This endpoint returns all featured collections on Pexels.
$collections = $pexels->featuredCollections(); // paginated $collections = $pexels->featuredCollection(new PaginationParameters(per_page: 80);
My Collections
This endpoint returns all of your collections.
$collections = $pexels->collections();
Collection media
This endpoint returns all the media (photos and videos) within a single collection. You can filter to only receive photos or videos using the type parameter.
$collection = $pexels->collection(id: 'someid'); // videos only $collection = $pexels->collection(id: 'someid', new CollectionParameters(type: 'Videos'));
Pagination
Most Pexels API requests return multiple records at once. All of these endpoints are paginated, and can return a maximum of 80 requests at one time. Each paginated request accepts the same parameters and returns the same pagination data in the response.
Note: The prev_page and next_page response attributes will only be returned if there is a corresponding page.
Contributors
devscast/pexels 适用场景与选型建议
devscast/pexels 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.2k 次下载、GitHub Stars 达 11, 最近一次更新时间为 2022 年 07 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「images」 「pexels」 「stock image」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 devscast/pexels 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 devscast/pexels 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 devscast/pexels 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova field for distribute your images as array of object.
Pexels API Client for www.pexels.com
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
A PSR-7 compatible library for making CRUD API endpoints
Convert and serve jpeg/png to webp with PHP (if at all possible)
Serve autogenerated WebP images instead of jpeg/png to browsers that supports WebP
统计信息
- 总下载量: 1.2k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 13
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-27