apsg / da-gallery-fetcher
deviantArt Gallery fetcher
Requires
- php: ^7.4|^8.0
- guzzlehttp/guzzle: ^7.2
- illuminate/contracts: ^8.0
- kamermans/guzzle-oauth2-subscriber: ^1.0
- laravel/framework: ^8.0
- spatie/laravel-package-tools: ^1.4.3
Requires (Dev)
- orchestra/testbench: ^6.13
- phpunit/phpunit: ^9.3
- spatie/laravel-ray: ^1.9
- vimeo/psalm: ^4.4
This package is auto-updated.
Last update: 2024-11-09 17:41:13 UTC
README
deviantArt gallery fetcher for Laravel. Use dA as data source and create awesome stuff (like a gallery!).
Installation
You can install the package via composer:
composer require apsg/da-gallery-fetcher
You can publish the config file with:
php artisan vendor:publish --provider="Apsg\Dafetcher\DafetcherServiceProvider" --tag="dafetcher-config"
This is the contents of the published config file:
return [ 'username' => env('DA_USERNAME'), 'cache' => true, 'oauth' => [ 'token_url' => 'https://www.deviantart.com/oauth2/token', 'client_id' => env('DA_CLIENT_ID'), 'secret' => env('DA_SECRET'), ], ];
The DA_USERNAME
variable is the default name of user you want to fetch the gallery (in most cases: your username).
Other variables (client ID and secret) can be obtained by registering your own OAUTH app here:
https://www.deviantart.com/developers/apps
Usage
$dafetcher = new Apsg\Dafetcher(); $collection = $dafetcher->fetch();
To change user just use fluent syntax:
$collection = $dafetcher->forUser('other-user')->fetch();
Disable cache
To disable cache permanently just set the config's variable cache
to false.
To disable temporarily just use helper:
$dafetcher = new Apsg\Dafetcher(); $freshResults = $dafetcher->noCache()->fetch();
DTOs
To fetch data and automatically transform it using DTOs:
$transformedResults = $dafetcher->fetchTransformed();
Testing
composer test
Credits
It uses great oauth2 subscriber for guzzle: https://github.com/kamermans/guzzle-oauth2-subscriber
License
The MIT License (MIT). Please see License File for more information.