2009年7月11日土曜日

phpで使用しているgooglecalendarをリストにしてすべて取得する方法。

Zend_Gdata_CalendarクラスのgetFeedの関数を使うと、Zend_Gdata_App_Feedのオブジェクトで返ってくる。
次にgetEntry()の関数を使い、 Zend_Gdata_App_Entryのオブジェクトが格納されたarrayで返す。
arrayだからcount($array)でarrayの数を数える。
あとは、Zend_Gdata_App_Entryのオブジェクトから必要なものだけとりだせばおっけ。


require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();
// ClientAuth 認証用のパラメータ
$service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
$user = "googleのアカウント";
$pass = "googleのパスワード";
// 認証済みの HTTP クライアントを作成します
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$service = new Zend_Gdata_Calendar($client);
$response = $service->getFeed('http://www.google.com/calendar/feeds/default/allcalendars/full','Zend_Gdata_App_Feed');

$entry = $response->getEntry();
$i = 0;
while($i<=count($entry)){
print $entry[$i]->id;
print "=";
print $entry[$i]->title;
print "<br/>";
$i += 1;
}

0 件のコメント:

コメントを投稿