1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

trying to get a list of events from a calendar using PHP

Discussion in 'Google API' started by paries, Aug 10, 2012.

  1. #1
    I am trying to get a list of events from a calendar.
    i am looking at google doc but i can not show the URL i am using in this post

    I assume that $service is created from $cal = new apiCalendarService($client); The doc is not very specific.

    when i try to execute the code below , i get the error
    PHP Fatal error: Call to a member function getItems() on a non-object

    but if i do this it works
    $calendarList = $cal->calendarList->listCalendarList();
    print "<h1>Calendar List</h1><pre>" . print_r($calendarList, true) . "</pre>";

    Also if i try the example code @
    i am looking at google doc but i can not show the URL i am using in this post

    I get the same kind of error
    PHP Fatal error: Call to a member function getItems() on a non-object

    This works:
     $events = $cal->events->listEvents('rtparies@gmail.com');    print "<h1>Events</h1><pre>" . print_r($events, true) . "</pre>";
    PHP:
    This fails:
    foreach($events->getItems()as $event){
        echo $event->getSummary();
      }
    
    PHP:

    I can not imagine all these examples are bad, so any suggestions on what i am doing wrong?

    The example is below :

    $calendarList = $service->calendarList->listCalendarList();
    while(true){
      foreach($calendarList->getItems()as $calendarListEntry){
        echo $calendarListEntry->getSummary();
      }
      $pageToken = $calendarList->getNextPageToken();
      if($pageToken){
        $optParams = array('pageToken'=> $pageToken);
        $calendarList = $service->calendarList->listCalendarList($optParams);
      }else{
        break;
      }
    }
    
    PHP:
     
    paries, Aug 10, 2012 IP