hamhamfonfon / astrobin-ws
Astrobin WebServices for PHP projects
Requires
- php: >=8.2.0
- ext-ctype: *
- ext-json: *
- guzzlehttp/guzzle: ^7.5
Requires (Dev)
- dg/bypass-finals: ^1.4
- phpunit/phpunit: ^10.0
- rector/rector: ^0.15.23
- squizlabs/php_codesniffer: 3.*
- dev-master
- 2.6.2
- 2.6.1
- 2.6.0
- 2.5.6
- 2.5.5
- 2.5.4
- 2.5.3
- 2.5.2
- 2.5.1
- 2.5.0
- 2.4.6
- 2.4.5
- 2.4.4
- 2.4.3
- 2.4.2
- 2.4.1
- 2.4.0
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.5
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.0
- 2.0.0
- 1.0.1
- 0.9.
- 0.8.0
- dev-update-php-8-2
- dev-pr-post-2.5.5
- dev-fix-typo-post-2.5.4
- dev-fix-typo-post-2.5.5
- dev-update-cpackage-rector
- dev-add-properties-views-and-likes
- dev-upgrade-php8.1
- dev-update-to-php74
- dev-fix-images-id-error
- dev-add-user-webservice
- dev-add-filters-for-image-webservices
- dev-add-histogram-and-skyplot
This package is auto-updated.
Last update: 2024-09-13 12:13:33 UTC
README
Astrobin API REST的WebServices
目录
版本 2.6.2
需求
- PHP 8.2 最小版本或更高(旧版本不再支持)
- Astrobin 的 API 密钥和 API 密码来自 Astrobin
介绍
Astrobin WebServices 是一个用于请求 Astrobin API REST 并获取在 Astrobin 上托管的美妙天体摄影的 PHP 库。请阅读“服务条款”中的 API 部分 "服务条款"
安装
您可以通过两种不同的方式安装此软件包。
- 基本安装;只需从 composer 安装包
composer require hamhamfonfon/astrobin-ws
更新到最新版本
composer update hamhamfonfon/astrobin-ws
如果您正在使用旧版本的 PHP
- PHP 8.1
composer require hamhamfonfon/astrobin-ws:2.5
- PHP 7.4 | 8.0
composer require hamhamfonfon/astrobin-ws:2.4
- PHP 7.3
composer require hamhamfonfon/astrobin-ws:2.3
注意,这些版本不再维护。只有 2.6.* 版本将得到维护并将有新功能。
- 如果您只想提出一些问题、做一些简单的测试等,只需克隆仓库
git clone git@github.com:HamHamFonFon/Astrobin-Webservices.git
使用
首先,将您的密钥设置在 .env 文件中
ASTROBIN_API_KEY=PutHereYourOwnApiKey ASTROBIN_API_SECRET=PutHereYourOwnApiSecret
无框架示例
# Get variables $astrobinApiKey = getenv('ASTROBIN_API_KEY'); $astrobinApiSecret = getenv('ASTROBIN_API_SECRET'); # Get data from Astrobin $imageWs = new GetImage($astrobinApiKey, $astrobinApiSecret); $astrobinImage = $imageWs->getById('astrobinImageId');
有 Symfony 示例
parameters: astrobinApiKey: '%env(ASTROBIN_API_KEY)%' astrobinApiSecret: '%env(ASTROBIN_API_SECRET)%' # default configuration for services in *this* file _defaults: autowire: true # Automatically injects dependencies in your services. autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. bind: $astrobinApiKey: '%astrobinApiKey%' $astrobinApiSecret: '%astrobinApiSecret%'
use AstrobinWs\Response\DTO\AstrobinResponse;use AstrobinWs\Services\GetImage; final class MyImageService { private GetImage $astrobinImage; /** * MyImageService constructor. * @param string|null $astrobinApiKey * @param string|null $astrobinApiSecret */ public function __construct(?string $astrobinApiKey, ?string $astrobinApiSecret) { $this->astrobinImage = new GetImage($astrobinApiKey, $astrobinApiSecret); } public function getImageById(): ?AstrobinResponse { return $this->astrobinImage->getImageById('1234'); } public function getOrionNebula(): ?AstrobinResponse { $orionNebula = $this->astrobinImage->getImagesBySubject('m42', 10); // ... return $orionNebula; } public function getImagesOfSiovene(): ?AstrobinResponse { $imagesBySiovene = $this->astrobinImage->getImagesByUser('siovene', 10); return $imagesBySiovene; } public function getImagesByManyFilters(): ?AstrobinResponse { $filters = [ 'user' => 'toto', 'subjects' => 'm31', 'description__icontains' => 'wind' ]; $listImages = $this->astrobinImage->getImageBy($filters, 10); return $listImages; } }
WebServices
该库公开了 3 个 WebServices,每个 WebServices 都有下面的方法。
GetImage
可以在 getImageBy()
中使用的过滤器列表
GetTodayImage
GetCollection
参数 $limit
是必需的,并且必须是整数。
GetUser
响应
图片
图片列表
收藏集
收藏集列表
今天
用户
贡献
我接受贡献,请fork该项目并提交 pull 请求。
错误和问题
如果您发现一些错误或对 Astrobin-WebServices 有任何疑问,请打开一个 issue,我会尽快回答您。
为调试安装包
检索代码源
从 GitHub 克隆仓库
git clone git@github.com:HamHamFonFon/Astrobin-WebServices.git
运行 docker
构建、编译并启动 docker 容器
docker-compose build --no-cache
docker-compose up -d
docker exec -ti php_astrobin_ws bash
安装
安装依赖
composer install
运行 Rector
# Init ./vendor/bin/rector init # Run ./vendor/bin/rector process src --dry-run
运行 PHP CodeSnifer
php ./vendor/bin/phpcs -p -n --standard=PSR12 src
应用 PHPCBF(修复和美化 PHPCS 错误)
php ./vendor/bin/phpcbf src/path/to/file.php
作者
Stéphane Méaudre - balistik.fonfon@gmail.com - 2023
许可
本项目采用 MIT 许可证 - 详细信息请参阅 LICENSE.md 文件