定制 vaweto/laravel-medium 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vaweto/laravel-medium

最新稳定版本:1.0.0

Composer 安装命令:

composer require vaweto/laravel-medium

包简介

This package hepls to fetch a recent feed of a medium.com

README 文档

README

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

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:

Usage

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

Installation

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),
    ],
];

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-01-02