PHP code example of prokerala / astrology-sdk

1. Go to this page and download the library: Download prokerala/astrology-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

prokerala / astrology-sdk example snippets




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
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) {
}

sh
curl -sS https://getcomposer.org/installer | php