1. Go to this page and download the library: Download hamhamfonfon/astrobin-ws 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/ */
hamhamfonfon / astrobin-ws example snippets
# 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');
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;
}
}
php ./vendor/bin/phpcbf src/path/to/file.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.