prokerala/astrology-sdk
Composer 安装命令:
composer require prokerala/astrology-sdk
包简介
Prokerala.com Astrology API Client Library for PHP.
README 文档
README
Prokerala Astrology SDK provides convenient access to Prokerala Astrology API for applications developed in PHP. Prokerala API integration helps you generate custom horoscope, perform horoscope matching, check mangal dosha, panchang and much more.
We have open sourced the code for our API demo at prokerala/astrology-api-demo.
Requirements
PHP needs to be a minimum version of PHP 8.0
Installation
If you prefer to work with the JSON response directly, please checkout our dependency free minimal PHP Client example that calls the API directly.
Using composer (recommended)
This is the recommended method for installation of the SDK.
Quick Installation
If you have composer already installed, and just want to get started quickly, the following command will install the SDK and its dependencies:
composer require prokerala/astrology-sdk:^1.0 nyholm/psr7 guzzlehttp/guzzle symfony/cache
That's it. The SDK is now ready to use. You can skip to the Usage section below.
Detailed Instructions
If you do not have composer already installed, you can install it with the following command on *nix systems.
curl -sS https://getcomposer.org/installer | php
If you are on Windows, follow the official documentation at getcomposer.org.
The current version of the SDK no longer ships with an HTTP client, instead depends on external implementations of PSR-17 (HTTP Message factory) and PSR-18 (HTTP client). You may choose any implementation of PSR-17 and PSR-18, for example, the following command installs nyholm/psr7 for PSR-17 and Guzzle HTTP client for PSR-18.
composer require nyholm/psr7 guzzlehttp/guzzle
Optionally, you can pass an implementation of PSR-16 Simple Cache interface for caching the access token and responses. As before, you can choose any implementation of PSR-16. The following command will install symfony/cache.
composer require symfony/cache
Now that you have all the dependencies installed, install the SDK by running the following command.
composer require prokerala/astrology-sdk:^1.0
Manual Installation
If you are not using composer, download the latest release from the releases section. You should download the zip file. After that include autoload.php in your application and you can use the API as usual.
For further help, Please visit our documentation
Usage
This SDK is powering our API demo page. The source code of the demos are open source and available on a separate GitHub repostiory.
<?php use Prokerala\Api\Astrology\Location; use Prokerala\Api\Astrology\Service\MangalDosha; use Prokerala\Common\Api\Authentication\Oauth2; use Prokerala\Common\Api\Client; use Prokerala\Common\Api\Exception\QuotaExceededException; use Prokerala\Common\Api\Exception\RateLimitExceededException; # Include composer autoloader include __DIR__.'/vendor/autoload.php'; # Create the PSR-17 Factory. The following line creates a PSR-17 factory using # nyholm/psr7. If you are using a different implementation, update accordingly. $psr17Factory = new \Nyholm\Psr7\Factory\Psr17Factory(); # Create the PSR-18 HTTP Client $httpClient = new \GuzzleHttp\Client(); # Create the PSR-16 Cache. Even though the cache parameter is optional, it is # highly recommended to pass a cache to Oauth2, to improve performance. $cache = new \Symfony\Component\Cache\Psr16Cache( new \Symfony\Component\Cache\Adapter\FilesystemAdapter() ); $authClient = new Oauth2('YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET', $httpClient, $psr17Factory, $psr17Factory, $cache); $client = new Client($authClient, $httpClient, $psr17Factory); $input = [ 'datetime' => '1967-08-29T09:00:00+05:30', 'latitude' => '19.0821978', 'longitude' => '72.7411014', // Mumbai ]; $datetime = new DateTime($input['datetime']); $tz = $datetime->getTimezone(); $location = new Location($input['latitude'], $input['longitude'], 0, $tz); try { $method = new MangalDosha($client); $result = $method->process($location, $datetime); $mangalDoshaResult = [ 'has_mangal_dosha' => $result->hasDosha(), 'description' => $result->getDescription(), ]; print_r($mangalDoshaResult); } catch (QuotaExceededException $e) { } catch (RateLimitExceededException $e) { }
Please check out our API Demo for a sample implementation using the SDK. The source code for the demo is available under the GitHub repository prokerala/astrology-api-demo.
License
Copyright © 2019-2022 Ennexa Technologies Private Limited. The Prokerala Astrology API PHP SDK is released under the MIT License.
prokerala/astrology-sdk 适用场景与选型建议
prokerala/astrology-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.32k 次下载、GitHub Stars 达 26, 最近一次更新时间为 2019 年 05 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 prokerala/astrology-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 prokerala/astrology-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 10.32k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 27
- 点击次数: 28
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-05-03