apsg/da-gallery-fetcher

deviantArt Gallery fetcher

0.1.1 2021-04-09 09:42 UTC

This package is auto-updated.

Last update: 2024-04-09 16:08:35 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

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();

See Full DTO's capabilities.

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.