开发者

Google Calendar/PHP newb question

开发者 https://www.devze.com 2023-03-11 06:39 出处:网络
I\'ve been scouring around for information through the google Calendar API, the Zend docs, and here, and just about everything I find seems to make assumptions on what I already know about PHP, so I\'

I've been scouring around for information through the google Calendar API, the Zend docs, and here, and just about everything I find seems to make assumptions on what I already know about PHP, so I'm just getting more lost. I do have a good deal of programming experience... with... um... a FORTH variant. Anyway! I'm trying to pass the output of a PHP script that can be used to get all of the important data from a calendar event into said FORTH variant. What's driving me up the wall is that I can't figure out how to grab something as simple as the UID of a message. Here's what I'm working with:

function outputCalendar($client) 
{
  $gdataCal = new Zend_Gdata_Calendar($client);
  $eventFeed = $gdataCal->getCalendarEventFeed();
  foreach ($eventFeed as $event) {
    ec开发者_运维问答ho $event->title->text .  " (" . $event->id->text . ")\n";
    foreach ($event->when as $when) {
      echo $when->startTime . "\n";
    }
  }
}

This is based off the example code they gave me, and instead of formatting with with XML tags like in the example, just puts each on its own new line (which is easier for me to pull into the other language.)

Now, I tried to add echo $when->startTime . "\n"; to the loop, but it just tells me:

Fatal error: Uncaught exception 'Zend_Gdata_App_InvalidArgumentException' with message 'Property uid does not exist' in /var/mucktools/Zend/Gdata/App/Base.php:484

So, obviously, I'm going about grabbing the UID the wrong way. Now, here's the thing. These two lines:

    echo $event->title->text .  " (" . $event->id->text . ")\n";
      echo $when->startTime . "\n";

...are pulling data from the event. However, 'title'. 'text', 'startTime' all look like things pulled out of one's posterior. I know, cognitively, that can't be true. There is a library and an API here. But I want to know where I can find a listing of all the crap I can pull out of $event and what the syntax is to do so. Can anyone help me with this?

And before you ask, yes, I have a very good reason to be grabbing the output of a PHP script and stuffing it into an obscure FORTH variant. And no, there's not another way that won't be more complicated than this one. I've done my homework here.


I'm sure you've read the documentation for Zend Gdata. It tells you that you need to provide getCalendarEventFeed() with a Zend_Gdata_Query object, otherwise I think you just get public data back.

Your code then should look something like this:-

$service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
$user = "user@gmail.com";
$pass = "userpassword";
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);

$gDataCal = new Zend_Gdata_Calendar($client);
$query = $gDataCal->newEventQuery();
$query->setVisibility('private');
$query->setProjection('full');
$query->setOrderby('starttime');
$query->setFutureevents('true');
$eventFeed = $gDataCal->getCalendarEventFeed($query);
foreach ($eventFeed as $event) {
    echo $event->title . " (" . $event->id . ")\n";
        foreach($event->when as $when){
            echo $when->startTime . "\n";
        }
}

Hopefully that should get you started in the right direction.

Also the php_openSSL module has to be enabled in PHP for this to work, but I assume you have that already enabled to get as far as you did.

0

精彩评论

暂无评论...
验证码 换一张
取 消