如何按开始日期订购Google日历Feed

时间:2013-01-24 11:57:29

标签: php zend-framework google-calendar-api

如何按开始日期订购Google日历Feed,这比现在更早?我尝试了很多不同的方法,但没有发生。我认为API有一些功能,但我无法让它们正常工作。抱歉我的英语不好!

这是我的代码

`

    function outputCalendar($client)

    {

    $gdataCal = new Zend_Gdata_Calendar($client);

    $eventFeed = $gdataCal->getCalendarEventFeed();





    $d = 0;

    foreach ($eventFeed as $event):

    $event->id->text = str_replace ("http://www.google.com/calendar/feeds/default/private/full/", "", $event->id->text);



      $descrEvent = $event->getContent();



    if(mb_strlen($descrEvent, "UTF-8") > 200)
        $descrEvent = mb_substr($descrEvent, 0, 200, "UTF-8")."...";          

    ?>



    <div class="slider-container">

    <span style="font-weight: bold;"><?= stripslashes($event->title->text); ?></span><br />

    <span class="st">Start date: <?= date('Y-m-d', strtotime($event->when['0']->startTime)); ?></span> 

    <span class="et">End date: <?= date('Y-m-d', strtotime($event->when['0']->endTime)); ?></span>

    <span class="st"><?= stripslashes($event->where['0']->valueString); ?></span><br />

    <span class="str"><?= stripslashes($descrEvent); ?></span>

    </div>

    <? 

    $d++;



    endforeach; 

    }



    require_once 'Zend/Loader.php';

    Zend_Loader::loadClass('Zend_Gdata');

    Zend_Loader::loadClass('Zend_Gdata_AuthSub');

    Zend_Loader::loadClass('Zend_Gdata_ClientLogin');

    Zend_Loader::loadClass('Zend_Gdata_Calendar');



    $user = 'killerskunk@gmail.com';

    $pass = 'mr_bean';

    $service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME; // predefined service name for calendar



    $client = Zend_Gdata_ClientLogin::getHttpClient($user,$pass,$service);



    outputCalendar($client);

    ?>`

1 个答案:

答案 0 :(得分:0)

我是通过插入

完成的
$query = $gdataCal->newEventQuery();
$query->setVisibility('private');
$query->setOrderby('starttime');
$query->setSortOrder('ascending');
$eventFeed = $gdataCal->getCalendarEventFeed($query);

$gdataCal = new Zend_Gdata_Calendar($client);