Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6870485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:41:22+00:00 2026-05-27T03:41:22+00:00

there are plenty of tutorials on how to request and parse a list of

  • 0

there are plenty of tutorials on how to request and parse a list of events from Google Calendar using Zend GData.

But all tutorials assume that events never repeat. (Kind of, they describe how to set up repeating events, but not how to parse / display them.)

So I wrote a script to copy events from Google Calendar to a web site, but it just doesn’t work because some of the events in the calendar are repeating and the method described in the tutorials results in pretty random output.

Any idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:41:23+00:00Added an answer on May 27, 2026 at 3:41 am

    I think I’ve finally found the answer you’re really looking for. Per http://code.google.com/apis/calendar/data/1.0/reference.html#Parameters, you need to set the ‘singleevents’ parameter to ‘true’, forcing the data returned to do it’s own parsing and ordering of recurring events. So your code (based on http://code.google.com/apis/calendar/data/1.0/developers_guide_php.html#RetrievingDateRange) will look something like:

    function outputCalendarByDateRange($client, $startDate='2007-05-01', $endDate='2007-08-01') {
      $gdataCal = new Zend_Gdata_Calendar($client);
      $query = $gdataCal->newEventQuery();
      $query->setUser('default');
      $query->setVisibility('private');
      $query->setProjection('full');
      $query->setOrderby('starttime');
      $query->setStartMin($startDate);
      $query->setStartMax($endDate);
    
      $query->setsingleevents('true');
    
      $eventFeed = $gdataCal->getCalendarEventFeed($query);
      echo "<ul>\n";
      foreach ($eventFeed as $event) {
        echo "\t<li>" . $event->title->text .  " (" . $event->id->text . ")\n";
        echo "\t\t<ul>\n";
        foreach ($event->when as $when) {
          echo "\t\t\t<li>Starts: " . $when->startTime . "</li>\n";
        }
        echo "\t\t</ul>\n";
        echo "\t</li>\n";
      }
      echo "</ul>\n";
    }
    

    The data that’s returned from this function has a single event for each instance of your repeating events, ordered correctly among all the rest of the “normal” events. Exceptions to the recurrance rules (single event cancellations, for instance) are correctly reflected, as well.

    So I think you can now use that method without any caveats or warnings…it should give you the data you want, in the way you want.

    You can probably do it without the second “foreach” loop, since each event should only have one “when” now…replace lines 18-20 with

    echo "\t\t\t<li>Starts: " . $event->when->startTime . "</li>\n";
    

    But since Google’s example does include that second foreach loop, it’s probably safer to leave it in.

    Hope it’s not too late to help you!

    —–Original answer:—–

    (included just for the sake of completeness and because I’m still using this basic method to combine events from multiple calendars)

    I’m working on this right now myself, using PHP to parse the feed and display some customized XML based on the data. The only solution I have come up with is to retrieve the dates/times of all the events, recurring or not, using:

    $eventFeed = $gdataCal->getCalendarEventFeed($query);
    foreach ($eventFeed as $event) {
        foreach ($event->when as $when) {
            $start=strtotime($when->startTime);
            $end=strtotime($when->endTime);
        }
    }
    

    Which works pretty well. The issue is that all the events will be returned “grouped” in order of the next occurances. That is, say it’s Monday right now. If you’ve got a repeating event every Tuesday and another repeating event every Thursday, and you ask it for all events in the next 90 days, the list you’ll get will first list every instance of the Tuesday event for the next 90 days, and THEN it will go on to list every instance of the Thursday event. For my purposes (and it sounds like, yours too), I wanted the list to be in order of the individual events coming up.

    The only way I’ve found to do it, is to insert the data from each individual instance into a temporary SQL database table, including a column indicating the timestamp of the event’s beginning. Then once it’s all entered in the database, I can request that it give me back the events, ordered by the timestamp.

    Thus my loop became something like:

    mysql_query("CREATE TEMPORARY TABLE `temp` (`title` TEXT NOT NULL,`date` TEXT NOT NULL,`timestamp` TIMESTAMP NOT NULL)");
    $eventFeed = $gdataCal->getCalendarEventFeed($query);
    foreach ($eventFeed as $event) {
        foreach ($event->when as $when) {
            $start=strtotime($when->startTime);
            $end=strtotime($when->endTime);
        mysql_query("INSERT INTO `temp` (`title`,`date`,`timestamp`) VALUES ('".$event->title->text."','".date("M d h:i a",$start)."-".date("h:i",$end)."','".date("Y-m-d H:i:s",$start)."')");
        }
    }
    $result=mysql_query("SELECT * FROM `mobile_app_events` ORDER BY `timestamp` ASC");
    while($row=mysql_fetch_assoc($result)) {
        echo "<item>\n";
        echo "<title>".$row['title']."</title>\n";
        echo "<date>".$row['date']."</date>\n";
        echo "</item>\n";
    }
    

    Now, I’ll caution you- the reason I’ve found this topic is because I’m looking for an answer myself…it seems that if the recurring events have any exceptions (for instance, next Thursday’s event is cancelled), that doesn’t get reflected in the output using these codes. Though next Thursday’s event is deleted from your Google Calendar view, it still shows up on this page.

    Other than that, (and assuming you’ve got access to a database), this seems to do the trick. I did add in a few lines to start a transaction before the process, with the theory that it might speed up the rendering of the data, not having to commit every insert.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are plenty of gallery plugins out there that rotate images but they all
I know there are plenty of tutorials about integrating C++ into Java, but whats
There are plenty of threads on how to create a Method using Reflection.Emit but
There's plenty of information on running Java apps as services, but I need to
I know there are plenty of books on C#, but I'd rather learn by
There are plenty of tutorials how to create multilanguage RESX files and how to
I have a word document I want to parse with C#. There are plenty
There are plenty of great answers to questions about making a standalone executable, but
There are plenty of discussing that shows how to load assemblies from BIN and
There is plenty of discussion for this regarding https. But do the headers get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.