Skip to content

Laravel package to enable crawling web pages for event data, generating corresponding ICS feeds

License

Notifications You must be signed in to change notification settings

ChrisHardie/laravel-calendar-crawler

Repository files navigation

Laravel package to enable crawling web pages for event data, generating corresponding ICS feeds

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

Installation

You can install the package via composer:

composer require chrishardie/laravel-calendar-crawler

You can publish and run the migrations with:

php artisan vendor:publish --provider="ChrisHardie\CalendarCrawler\CalendarCrawlerServiceProvider" --tag="calendar-crawler-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --provider="ChrisHardie\CalendarCrawler\CalendarCrawlerServiceProvider" --tag="calendar-crawler-config"

This is the contents of the published config file:

return [
    'default_update_frequency' => 720, // Refresh every 12 hours

    'calendar_name' => 'Calendar of Events',

    'calendar_description' => 'A calendar of events from various sources.',

    // Default URL of calendar ICS feed
    'stream_url' => '/calendar/calendar.ics',

    // Source-specific authentication information
    'auth' => [
        'google' => [
            'api_key' => env('GOOGLE_CAL_API_KEY'),
        ]
    ],
];

You can add a web route for a calendar ICS feed of all stored events:

Route::calendarstream();

Usage

  1. Use an admin interface, artisan tinker session, DB seeder file or direct database call to add calendar sources. The main fields needed are:
  • Name
  • Type (currently, GoogleCalendar or FacebookPage)
  • Home URL
  • Location (either the Google Calendar calendar ID or the Facebook Page's numeric page ID)
        DB::table('calendar_sources')->insert([
            'name' => 'Your Local Government',
            'type' => 'GoogleCalendar',
            'home_url' => 'https://www.government.gov/',
            'location' => 'googlecalendarid@gmail.com',
        ]);

        DB::table('calendar_sources')->insert([
            'name' => 'Cool Nonprofit Organization',
            'type' => 'FacebookPage',
            'home_url' => 'https://www.facebook.com/orgname/',
            'location' => '12345678',
        ]);
  1. If you specify any GoogleCalendar sources, you will need to create an API key and then define a GOOGLE_CAL_API_KEY with that key as the value in your .env file.
  2. The sources provided will be crawled according to the update frequency specified.
  3. Use the event data elsewhere within your Laravel application directly, or retrieve an ICS calendar feed of events at the stream_url location specified.

Crawling issues, errors and notices will be written to the log stack configured. Consider using a Slack channel for convenience.

Uninstalling

Remove any web routes created during installation.

Remove the package and any dependencies:

composer remove chrishardie/laravel-calendar-crawler

Remove config/calendar-crawler.php.

Drop the related tables in a new migration:

Schema::dropIfExists('calendar_sources');
Schema::dropIfExists('events');

Changelog

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

Contributing

Please see CONTRIBUTING for details.

Credits

License

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

About

Laravel package to enable crawling web pages for event data, generating corresponding ICS feeds

Resources

License

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

 
 
 

Languages