0
votes

I've created my own events calendar using a WordPress custom post type and I need to make the calendar subscribable to Google Calendar and the Mac OSX calendar app. The Mac calendar is working perfectly, but Google's having issues.

I used this website's script as a foundation to create my own script that generates my iCal file: http://www.noeltock.com/web-design/wordpress/how-to-ical-with-custom-post-types/

I've scoured through this site trying to make sure I had all the necessary fields: http://www.kanzaki.com/docs/ical/

I've also compared my generated iCal file to the one generated by the WP plugin Events Calendar Pro.

When I click the Mac absolute link (using webcal instead of http), it launches the app and loads the events in the file just fine.

When I click the Google link (using /render?cid=feed), it opens a tab asking if I want to add the calendar. I click yes and then get hit with an error saying I don't have access to that calendar.

Here's an example of my generated iCal file:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Site Name//NONSGML Events //EN
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:Site Name
X-ORIGINAL-URL:Site URL
X-WR-CALDESC:Site Description

BEGIN:VEVENT
DTSTART;VALUE=DATE-TIME:20140401T070000
DTEND;VALUE=DATE-TIME:20140401T230000
DTSTAMP:20140326T001707
CREATED:20140103T041301
LAST-MODIFIED:20140325T150531
SUMMARY:April Fool's Day
CLASS:PUBLIC
DESCRIPTION:Blah blah blah
END:VEVENT

END:VCALENDAR

Can someone please tell me what I'm missing? I've been fighting with this for two weeks and my client wants to launch his site. Thank you in advance!

1

1 Answers

1
votes

Are you setting headers?

header( 'Content-Type: text/Calendar' );
header( 'Content-Disposition: inline; filename=calendar.ics' );

For Google you can build a query string link. Here is how I'm doing it and it works fine.

$google => array(
                'label' => 'Google',
                'icon'  => get_template_directory_uri() . '/images/common/ico_google.png',
                'url'   => 'http://www.google.com/calendar/event?action=TEMPLATE&trp=false'
                    . '&text='    . $title
                    . '&details=' . $description
                    . '&dates='   . $date_start->format( $date_format )
                    . '/'         . $date_end->format( $date_format ),
            );

<a href="<?php echo esc_url( $google['url'] ) ?>" class="<?php echo esc_attr( $google['url'] ) ?>" rel="external" target="_blank">