With this package you can get the rss feed of any valid Medium tag or user you want as objects in order to make a feed on you application. You can use your database to store the feeds you want to watch or you can call them hardcoded by specify the name of the feed and the type of the feed (user or tag).
Here's a quick example:
Get a specific feed hardcoded
use Vaweto\Medium\Facades\Medium;
use Vaweto\Medium\Definitions\MediumFeedType;
$articles = Medium::getFeed('laravel', MediumFeedType::TAG)->getArticles();
Get a specific feed from database
use Vaweto\Medium\Facades\Medium;
use Vaweto\Medium\Models\MediumFeed;
$mediumFeed = MediumFeed::query()->first();
$articles = Medium::getFeed(mediumFeed)->getArticles();
Get a multiple feeds from database
use Vaweto\Medium\Facades\Medium;
use Vaweto\Medium\Models\MediumFeed;
$mediumFeeds = MediumFeed::query()->all();
$articles = Medium::all(mediumFeeds);
Use it in your controller
use Vaweto\Medium\Facades\Medium;
use Vaweto\Medium\Models\MediumFeed;
class MediumFeedControllerController
{
public function __invoke(Invoice $invoice)
{
$articles = Medium::all(MediumFeed::query()->all());
return view('your-feed-blade', compact('articles'));
}
}
And on your blade
@foreach ($articles as $article)
<div>
<h2>{{ $article->title }}</h2>
<p>{{ $article->pubDate->toDateTimeString() }}</p>
<a href="{{ $article->guid }}" target="_blank">Read More</a>
</div>
@endforeach
You can install the package via composer:
composer require vaweto/laravel-medium
You can publish and run the migrations with:
php artisan vendor:publish --tag="medium-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="medium-config"
This is the contents of the published config file:
return [
'api_token' => env('MEDIUM_API_TOKEN'),
'feed_urls' => [
'user' => 'https://medium.com/feed/',
'tag' => 'https://medium.com/feed/tag/',
],
'caching' => [
'enabled' => env('MEDIUM_CACHING', false),
'time_in_seconds' => env('MEDIUM_CACHING_TIME_IN_SECONDS', 120),
],
];
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.