AS3 library for Google Calendar (as3googlecalendarlib)

I created an AS3 library for Google Calendar API. This library has following features implemented.

  1. Authenticating to the Calendar service
  2. Retrieving calendar lists
  3. Retrieving all calendars
  4. Retrieving only calendars that a user owns
  5. Managing calendars
  6. Creating new calendars
  7. Updating existing calendars
  8. Deleting calendars
  9. Retrieving events for a specified date range
  10. Creating single-occurrence events
  11. Updating events
  12. Deleting events
  13. Reminders and Notifications

Please download the library from this URL http://as3googlecalendarlib.googlecode.com

All you have to do is to use the classes in the com.adobe.googlecalendar.services package to use any of the feature mentioned above.

This library still needs to be improved, in terms of adding more features, code cleanup, documentation and implementing any suggestions. I will try to complete this as soon as possible.🙂

If you are interested in contributing to this library, please let me know. If you want to use this and want to know how to, leave a comment.

I am in process of creating an AIR application using this API, I will be posting soon.🙂

71 Responses to AS3 library for Google Calendar (as3googlecalendarlib)

  1. Danilo says:

    Nice idea. I will take a look.

  2. Thomas says:

    Very cool, I’ll check it out!

  3. Murali says:

    Good one🙂 It will be of great use for many of us.

  4. Charles says:

    Hi Sujit, I would like to use your library, I have searched the provided google code link but I didn’t find any file to download. Can you provide a link to download it? Thanks.

  5. Tmobetta says:

    I’m very interested in using your library and its functionality in my web app, but am brand new to Flex programming. Please explain how I can put into my app and make it work. thanks

  6. Sujit Reddy G says:

    Hi Charles,

    Please download the code as explained in this URL http://code.google.com/p/as3googlecalendarlib/source/checkout

    Hope this helps.

  7. Sujit Reddy G says:

    Hi Tmobetta,

    I am working on an AIR application which will use this API and will be posting that soon. Please download the API and look at the classes in com.adobe.googlecalendar.services package. Names of the functions are pretty straightforward. I will post sample ASAP🙂

  8. Paolo says:

    There’s a sample FLEX MXML application for this library ? Some help?
    Thanks

  9. Sujit Reddy G says:

    Hi all,

    I am working on a sample application using this API .. I promise to post it by 16th Feb …..🙂

  10. mango says:

    Hi, Thanks for writing the library. Are there any pointers for how to use it? I’m new to AS3/Flash/Flex and even a short explanation would be very useful.

  11. Paolo says:

    Hi Sujit! We are waiting for a sample about your great library!!!!🙂 I’ve tried to use it into a Flex app but i get only security errors…

  12. […] as3googlecalendarlib documentation | Not finding much time to work on the as3googlecalendarlib (https://sujitreddyg.wordpress.com/2009/01/29/as3-library-for-google-calendar-as3googlecalendarlib/) or the sample application using the library. I managed to create a simple API documentation for […]

  13. Paolo says:

    Hi Sujit.
    The error is:
    RPC Fault – Security Error accessing url – Channel.security.error – Destination: DefaultHTTP

  14. Hi all,

    I posted API docs and code samples for this library. More details at the URL below. This library might not work with Flex application running on Flash Player on browsers, cause Authenticate headers are blocked by Flash Players unless domain (Google in this case) has a cross domain policy which allows Authenticate headers. Please develop AIR applications. AIR rocks🙂

    https://sujitreddyg.wordpress.com/2009/02/19/documentation-for-as3googlecalendarlib/

    Thanks.🙂

  15. Hi Paolo,

    This error shouldn’t be caused by this library. Please share the code to reproduce this. Send it to sujitreddy.g@gmail.com

    Thanks.

  16. Fahrudin Paljush says:

    hi..
    when i try to add event to calendar(i try and when create new calendar, and when i try to load old) this error message
    Error #2032: Stream Error. URL: http://www.google.com/calendar/feeds/default/owncalendars/full

    Can you help me ?
    farko.p@gmail.com

  17. Hi Fahrudin,

    Please run the application in debug mode and find HTTP status code in the console and share that. I couldn’t understand what you are trying to do, please try sending the code to reproduce this to sujitreddy.g@gmail.com.

    Thank you.

  18. sudheer says:

    hi,
    I’m getting same error. HTTP status code is 403.

  19. sudheer says:

    INFORMATION : Sending authentication request
    INFORMATION : Authentication request sent
    INFORMATION : Authentication response recieved
    INFORMATION : Parsed response
    INFORMATION : Authentication successful
    DEBUG : Add calendar XML created
    DEBUG : Sent request to add calendar to this URL: http://www.google.com/calendar/feeds/default/owncalendars/full
    INFORMATION : Authentication response event dispatched
    DEBUG : HTTPStatus event for adding calendar invoked: 403
    DEBUG : Fault function of add calendar invokedError #2032: Stream Error. URL: http://www.google.com/calendar/feeds/default/owncalendars/full
    DEBUG : Dispatched GoogleCalendarServiceEvent.ADD_CALENDAR_FAULT event

  20. jimmi4u says:

    Hi all,

    how do you use the authentication method? I can’t do it. I’ve generated an API key, and an OAuth Consumer Secret for the webpage, but when I try to run the code I get only this:
    INFORMATION : Sending authentication request
    INFORMATION : Authentication request sent
    DEBUG : Add calendar XML created
    DEBUG : Sent request to add calendar to this URL: http://www.google.com/calendar/feeds/default/owncalendars/full
    and than the creationComplete tells me that: source not found and a button to edit the lookup source and than it tells me something like sandbox security error:
    Error #2044: securityError unverarbeitet. text=Error #2170: Verletzung der Sicherheits-Sandbox: file:///Flex Builder 3/…/bin-debug/main.swf kann keine HTTP-Header an http://www.google.com/calendar/feeds/default/owncalendars/full senden.
    Here is the code taken from the code samples:

    public function onLoad():void
    {

    var calendar:GoogleCalendarVO = new GoogleCalendarVO();
    calendar.setTitle(“test”);
    calendar.setSummary(“calendar summary”);
    calendar.timeZone = “Europe/Vienna”; //only few are supported. Check GoogleCalendarVO class
    calendar.color = “#A32929”;
    calendar.hidden = false;
    calendar.addWhere(“Vienna”);

    var _authenticate:GoogleCalendarAuthenticator = new GoogleCalendarAuthenticator();
    _authenticate.addEventListener(GoogleCalendarAuthenticatorEvent.AUTHENTICATION_RESPONSE, doCalendar);
    _authenticate.addEventListener(GoogleCalendarAuthenticatorEvent.AUTHENTICATION_FAULT, errorEvent);

    _authenticate.authenticateUser(“user”, “pwd”, “API-key”);

    var _calendarService:GoogleCalendarService = new GoogleCalendarService();
    _calendarService.addEventListener(GoogleCalendarServiceEvent.ADD_CALENDAR_FAULT,handleAddCalendar);
    _calendarService.addEventListener(GoogleCalendarServiceEvent.ADD_CALENDAR_RESPONSE,handleAddCalendar);

    var user:GoogleCalendarUserVO = new GoogleCalendarUserVO();
    user.userName = “user”;
    user.userPassword = “pwd”;
    user.authenticationToken =”Token taken from the oath-authentication when testing on google”;

    var cal:GoogleCalendarVO = new GoogleCalendarVO();
    if(cal != null)
    {
    _calendarService.addCalendar(cal, user);
    }
    }
    what am I doing rong?
    please help.
    Thank you.
    jimmi4u

  21. sudheer says:

    hi,
    i’m using this project in an air application.
    it authenticates successfully but when adding the calendar i get the following error:
    DEBUG : HTTPStatus event for adding calendar invoked: 403
    DEBUG : Fault function of add calendar invokedError #2032: Stream Error. URL: http://www.google.com/calendar/feeds/default/owncalendars/full
    DEBUG : Dispatched GoogleCalendarServiceEvent.ADD_CALENDAR_FAULT event

  22. Hi Sudhir,

    Google calendar server is throwing this error when a API is invoked for a first time from a system. I haven’t found anything fault in the library, still trying to figure out reason for this. Kindly let me know if this problem is occurring every time.

    Hope this helps.

  23. Hi Jimmi,

    Please find below sample on how to send authentication request.

    Sending authentication request.

    calendarAuthenticator.addEventListener(GoogleCalendarAuthenticatorEvent.AUTHENTICATION_RESPONSE,
    handleAuthenticationResponse);
    calendarAuthenticator.addEventListener(GoogleCalendarAuthenticatorEvent.AUTHENTICATION_FAULT,
    handleAuthenticationResponse);
    calendarAuthenticator.authenticateUser(userName,userPassword);

    Getting authenticated GoogleCalendarUserVO object. You should use the authenticationToken in the object instance below.
    private function handleAuthenticationResponse(event:GoogleCalendarAuthenticatorEvent):void
    {
    var userObj:GoogleCalendarUserVO;
    userObj = event.authenticatedUser;
    }

    Hope this helps.

    I am sorry I cannot find time to document.😦

  24. sudheer says:

    yes this error happens everytime. can’t find any problem with the code

  25. rsoares says:

    Hi all!

    I want to use this library and want to know how.

    Thank you🙂

  26. Gireesh says:

    is there any sample project posted??

    thanks
    Gireesh

  27. I Singh says:

    Is your lib not working with Flash AS3.0?

  28. Rahul says:

    Hi,

    I am facing problem while retrieving events for a single day. the request doesn’t return anything in the response. But in case I change the duration from a single day to a month, then all those events are shown. Any idea where I might b wrong?

    Thanks

  29. chandra says:

    Hi,

    I am facing problem whiel updating the event.
    from flash app to googlecalendar API. problem is
    i am updating the event as googlecalendareventvo
    in that
    what,when,where,calendar,descrition are the fields to update. but when i pass startdatetime and enddatetime to when i am getting error like null object reference.

    pls let me know if u have idea how to update event in calendar using flash as3

  30. I Singh says:

    It is not working for simple flash app. I think that need google cal webased authentication. Any Idea to implement it in flash.

  31. Hi Rahul,

    Not sure. Please try sharing the code to reproduce this. I can see if I can find the problem. Thanks.

  32. I Singh says:

    Can you please modify this API for flash , now it is working only for AIR app.

    Thanks in advance.

  33. Hi I Singh,

    I don’t think Google has crossdomain policy files on their servers yet.

  34. I Singh says:

    Any other solution for it.

  35. liutenantdan says:

    Hi. I’m running your code in an AIR application. When I run the authentication, the response comes back twice. The only listener involved is the following:

    “var token:AsyncToken = authenticationService.send(params);
    token.addResponder(new Responder(handleAuthenticationResult, handleAuthenticationFault));”

    Is there a reason why the response handler is firing twice? The send() call is not duplicated anywhere, so I’m kinda lost on this one…

  36. liutenantdan says:

    GOT IT..

    appears to be a bug in 3.4

    apparently it’s been fixed for 3.5

    😀

  37. LKW says:

    Hi
    I want to use this library. May I have a copy? Thank you

  38. Alex Fisherr says:

    Dear Sudheer,

    I was having the same problem as well. Just figured out that it was the color property of the GoogleCalendarVO object not set that caused this error. Set the property, I used “#2952A3”, and that’ll be solved.
    Best of luck … !!!

  39. Tahir Alvi says:

    Hi Everybody.
    The google calendar api is useful, but i have not see any real application of flex that uses this api. maybe it is built up but not see by me.

    if anybody have see it please share at
    alvijee@gmail.com

  40. Hi I Singh,

    As of now I don’t think they have cross domain policy file enabled for google calendar servers. So it will not be possible to send requests from web applications hosted outside google servers.
    PS: I haven’t checked recently.

    Hope this helps.

  41. Mac fly says:

    Hello,
    There are some news from the sample application to know how use this library.
    Thanks.

  42. Koray Yersel says:

    Hi Sujit,

    I’ve managed to use your library for a Flex project (not AIR!). I’ve used a Java-Proxy servlet for this. And I had to made some changes in your project. But your library was very very helpful thx!

    You can check my google wave (flex) gadget using this library and the proxy I’ve mentioned from yersel.blogspot.com. From time to time I’ll post the source code in my blog. Feel free to test it and leave your comments.

    I’ve found a tiny bug in your code regarding to creating events. I’ve already posted it your google code page.

    Regards,
    Koray

  43. Tahir Alvi says:

    Hi Sing G.
    I have need to know that why we add a calendar , and when we adding a new calendar the 2nd parameter is googlecalendaruserVo.
    what is that mean.
    Are it is that when we logged in?
    Thanks

  44. Tahir Alvi says:

    Hi Sing G

    Please give me some help how i get all added calendars.

    Thanks

  45. Alex Fisherr says:

    Hi Sujit,Koray

    I am trying to add an event using the API. It doesn’t work in first attempt.It shows
    following Error.

    Error #2032: Stream Error. URL: http://www.google.com/calendar/feeds/5hegva8q7hrsk50elca1i0j4m8%40group.calendar.google.com/private/full

    Every time after first effort, when I call the GoogleCalendarEventService’s addEventToCalendar method, the event is successfully added and visible on google’s web page . Could you pleae explain help me out in this?
    I watched the XML and it is exactly same. I was trying to upload that but my comments were being discarded. So I am not uploading the XMLs here.

    Any help in this regards would be highly appreciated.
    Regards,
    Fisherr

  46. Tahir Alvi says:

    Hi Sing G.

    I want to got update a calendar, i also post 2 question please bypass it, i solve those problems, but now i want to know how i update or delete a calendar.?
    Thanks

  47. Jason says:

    This is just what the doctor ordered for my app!

    I am not getting the list of calendars I have in my account. Here is console debug information:

    INFORMATION : Sending authentication request
    INFORMATION : Authentication request sent
    INFORMATION : Authentication response recieved
    INFORMATION : Parsed response
    INFORMATION : Authentication successful
    INFORMATION : Sending request for owned calendars to url http://www.google.com/calendar/feeds/default/owncalendars/full
    DEBUG : Sent request for owned calendars to url http://www.google.com/calendar/feeds/default/owncalendars/full
    INFORMATION : Authentication response event dispatched
    DEBUG : Received success response for get owned calendars
    DEBUG : Calendars created
    DEBUG : Parsed response and created calendar objects

    So I get authenticated fine and it tries to get the owned calendars. But if I explore the owned calendars variable, it says length of ‘0’ and there’s nothing in the array…

    I see people talking about an API key. Is this required? If so, is this the key you get from the XML link? (/private-asdfa239sdfwer/ etc…) Am I missing something totally obvious?

    thanks all!
    -j

  48. Hi Tahir,

    Please try the updateCalendar and deleteCalendar functions in the CalendarService.

    Hope this helps.

  49. Hi Fisherr,

    Google calendar server is throwing this error when a API is invoked for a first time from a system. I haven’t found anything fault in the library, still trying to figure out reason for this. Kindly let me know if this problem is occurring every time.

    Hope this helps.

  50. Hi Koray,

    I checked out the Google wave application .. its great🙂 Thanks for logging the bug, will fix that🙂

  51. Tahir Alvi says:

    Hi Sujit Reddy G.

    Thanks for your answer of my last question.

    Please tell me how i share the calendar with specific people or calendar events with him.

    Thanks

  52. héy Sujit
    Nice work on the GCAL class!
    I’ve throrougly enjoyed my time developing a tiny app using yr class.
    Noticed a few flukes though, was wondering if you are interested in my findings and discussing the possible solutions for some of them.

    Kind regards and thanks again for the wonderful package.
    Tommy

  53. Leong Ka Wing says:

    Why I can’t find any library for download at that site?

  54. Leong Ka Wing, check out the source > svn checkout link

  55. Macky Pulido says:

    Hi,

    Can we have an update sample for the Google Calendar Library.

    Thanks and good luck!

    Macky

  56. Filippo says:

    Hi Sujit Reddy G.,

    after I’ve establish the connection with GoogleCalendar, getting a good feedback for the AUTHENTICATION_RESPONSE event but not for the GET_OWNED_CALENDARS_RESPONSE, I’ve decided to add my own calendars using an iframe.
    I can display the events for every single calendar but I can’t display the events for many calendars in the same view.

    Can you please help me or giving me a suggestion?

  57. CyberDave says:

    THANKS FOR THIS CONTIRBUTION!

    will it also work sdk 4.0 ?😉

    thank you!

  58. Jeremi says:

    i can’t find the library to download on the google code website.
    where is it???

    please post direct link.

  59. koon says:

    Hi Sujit Reddy G.,

    I have created an app but when I run it I am unable to retrieve the Calendar.

    I will receive HTTP request Error.

    Can you please assist me.

    Thank You.

  60. tsu says:

    Thanks for the great library.
    I’ve made a mock program for test as below.
    But got #2032 Error.
    (Air application with Flex4. Flex3 might be same)

    I found a related comment
    “Google calendar server is throwing this error when a API is invoked for a first time from a system.”
    but #2032 error is apeared every time.

    any suggestions ?

    thanks.

    private var calendarEventsService:GoogleCalendarEventsService;
    private var googleCalendarAuthenticator:GoogleCalendarAuthenticator = new GoogleCalendarAuthenticator();
    private var authenticatedUser:GoogleCalendarUserVO;
    private var googleCalendarService:GoogleCalendarService;
    private var ownedCalendars:ArrayCollection;

    protected function creationComplete():void{
    googleCalendarAuthenticator.addEventListener(GoogleCalendarAuthenticatorEvent.AUTHENTICATION_RESPONSE,authenticatorResponse);
    googleCalendarAuthenticator.addEventListener(GoogleCalendarAuthenticatorEvent.AUTHENTICATION_FAULT,function(event:GoogleCalendarAuthenticatorEvent):void{
    });
    googleCalendarAuthenticator.authenticateUser(“xxxx@gmail.com”,”xxxx”);
    }
    protected function authenticatorResponse(event:GoogleCalendarAuthenticatorEvent):void{
    authenticatedUser = event.authenticatedUser;
    getOwnedCalendars();
    }
    protected function getOwnedCalendars():void{
    googleCalendarService = new GoogleCalendarService();
    googleCalendarService.addEventListener(GoogleCalendarServiceEvent.GET_OWNED_CALENDARS_RESPONSE,getOwnedCalendarsResponse);
    googleCalendarService.addEventListener(GoogleCalendarServiceEvent.GET_OWNED_CALENDARS_FAULT,function(event:GoogleCalendarServiceEvent):void{
    });
    googleCalendarService.getOwnedCalendars(authenticatedUser);
    }
    protected function getOwnedCalendarsResponse(event:GoogleCalendarServiceEvent):void{
    ownedCalendars = event.ownedCalendars;
    }
    protected function btn_click():void{
    calendarEventsService = new GoogleCalendarEventsService();
    var calEvent:GoogleCalendarEventVO = createCalendarEventVO();
    if(calEvent != null)
    {
    calendarEventsService.addEventListener(GoogleCalendarEventsServiceEvent.ADD_EVENT_RESPONSE, handleAddEventResponse);
    calendarEventsService.addEventListener(GoogleCalendarEventsServiceEvent.ADD_EVENT_FAULT, handleAddEventFault);
    calendarEventsService.addEventToCalendar(calEvent, GoogleCalendarVO(ownedCalendars.getItemAt(0)), authenticatedUser);
    }
    }
    private function handleAddEventResponse(event:GoogleCalendarEventsServiceEvent):void{
    }
    private function handleAddEventFault(event:GoogleCalendarEventsServiceEvent):void{
    // ################### //
    // Error #2032: Stream Error. URL: http://www.google.com/calendar/feeds/xxxx%40gmail.com/private/full
    trace(“handleAddEventFault”);
    }

    private function createCalendarEventVO():GoogleCalendarEventVO {
    var calEvent:GoogleCalendarEventVO = null;
    calEvent = new GoogleCalendarEventVO();
    calEvent.setTitle(“Event title”);
    calEvent.setContent(“Event description”);
    calEvent.addWhere(“In my office”);
    calEvent.visibility = GoogleCalendarEventUtil.VISIBILITY_DEFAULT;
    calEvent.transparency = GoogleCalendarEventUtil.TRANSPARENCY_OPAQUE;
    calEvent.eventStatus = GoogleCalendarEventUtil.STATUS_CONFIRMED;
    var whenObj:WhenVO = calEvent.addWhen(new Date(),new Date(),true);
    whenObj.addReminder(0,1,0, ReminderVO.ALERT_METHOD_EMAIL);
    return calEvent;
    }

  61. Antonio says:

    Hi Sujith,
    how I can do authentication, get my calendars, but I can’t add an event to the calendar selected.
    Can you help me?
    Can you post an example with authentication, retrieve calendars, and add an event to a calendar?
    Thanks in advance

  62. todd says:

    hi sujit,
    thanks for the great library!
    i’ve run into an issue similar to one mentioned above:
    after successfully authenticating, i attempt to retrieve owned calendars but get an error. My logs show this :
    ‘DEBUG : Sent request for owned calendars to url http://www.google.com/calendar/feeds/default/owncalendars/full
    DEBUG : Get owned calendars error
    DEBUG : Dispatched GoogleCalendarServiceEvent.GET_ALL_OWNED_FAULT event’

    My debug session shows this FaultEvent :
    fault – mx.rpc.fault
    fault.content –
    ‘Content-Type application/x-www-form-urlencoded is not a valid input type’
    fault.faultCode – Server.Error.Request
    fault.rootCause – flash.events.IOErrorEvent
    fault.rootCause.m_texg – Error #2032: Stream Error. URL: http://www.google.com/calendar/feeds/default/owncalendars/full

    any suggestions?

  63. todd says:

    oh yeah,
    forgot to mention i am able to create a calendar successfully after authentication.
    also, is there any way you could post the source from the app you built? the one you reference in your ‘Documentation’ post.

  64. todd says:

    hi again sujit,
    it looks like i may have found a solution.
    in GoogleCalendarService the calendarService.method is set to ‘POST’ in the constructor.
    when triggering getOwnedCalendar() calendarService.method should be set to ‘GET’.
    adding the following to line 135,
    before var token:AsyncToken = calendarService.send(), did the trick for me.

    calendarService.method = ‘GET’;

  65. Maria says:

    How do i download the library? cant download it from the browser.
    Thanks

  66. sanjay says:

    Hi,
    I am able to create new calendar but when I am trying to get user own calendar i am getting error “HTTP request error”.

    INFORMATION : Sending authentication request
    INFORMATION : Authentication request sent
    INFORMATION : Authentication response recieved
    INFORMATION : Parsed response
    INFORMATION : Authentication successful
    INFORMATION : Sending request for owned calendars to url http://www.google.com/calendar/feeds/default/owncalendars/full
    DEBUG : Sent request for owned calendars to url http://www.google.com/calendar/feeds/default/owncalendars/full
    INFORMATION : Authentication response event dispatched
    DEBUG : Get owned calendars error HTTP request error
    DEBUG : Dispatched GoogleCalendarServiceEvent.GET_ALL_OWNED_FAULT event

  67. Mike says:

    Your lib will definitely help us to create a nice google calendar clone for flex😉. Check out our lib here:

    http://flex-calendar.com/demo

  68. Robert says:

    Having same problem as everyone else with retrieving own calendars. Tried Todd’s suggestion re “PUT” but that didn’t work for me😦
    INFORMATION : Sending authentication request
    INFORMATION : Authentication request sent
    INFORMATION : Authentication response recieved
    INFORMATION : Parsed response
    INFORMATION : Authentication successful
    INFORMATION : Sending request for owned calendars to url http://www.google.com/calendar/feeds/default/owncalendars/full
    DEBUG : Sent request for owned calendars to url http://www.google.com/calendar/feeds/default/owncalendars/full
    INFORMATION : Authentication response event dispatched
    DEBUG : Get owned calendars error HTTP request error
    DEBUG : Dispatched GoogleCalendarServiceEvent.GET_ALL_OWNED_FAULT event
    Any ideas what’s going wrong here???????

  69. saurabhsachdeva says:

    Hi Sujit,

    I am a java developer and I am new to flex/Air development. I am trying to create an air application , which i am going to sell to consumers , hopefully for MAC. I have a question, actually its a two part question.

    1) Can i use your library in my project , and then sell my app?

    2) Does google allow us to integrate our applications with google calendar ,in this case using your library and then sell our applications in the market? I mean can we commercialize our apps using google services? There documentation is very confusing , i have been checking blogs and everything and couldn’t confirm a result out of it.

    With your experience i am sure you will be able to help me with this. Here is a link to my blog , just in case:
    saurabhsachdeva.wordpress.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: