【发布时间】:2014-11-19 21:38:27
【问题描述】:
您好,我正在尝试将我的 php 脚本 v2 api 迁移到 v3,但我不知道该怎么做...
我阅读了 Google Calendar API 3.0 版迁移指南,但不知道是否可以与 zend_gdata 一起使用或如何操作..
<?php
} else {
// load classes
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');
Zend_Loader::loadClass('Zend_Http_Client');
// connect to service
$title = $_POST['ACTUACION']."/".$_POST['NOMBRE']."/".$_POST['TELEFONO'];
$title = strtoupper($title);
$where = $_POST['MUNICIPIO']."/".$_POST['DIRECCION'];
$where = strtoupper($where);
$description = $_POST['CAPTACION']."/".$_POST['ESTADO']."/".$_POST['PROCEDENCIA'].$_POST['PROCEDENCIA2']."/".$_POST['REFPROCEDENCIA'];
$description = strtoupper($description);
$gcal = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
$user = $_POST['email'];
$pass = $_POST['pass'];
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $gcal);
$gcal = new Zend_Gdata_Calendar($client);
// validate input
if (empty($title)) {
die('ERROR: Missing title');
}
if (!checkdate($_POST['sdate_mm'], $_POST['sdate_dd'], $_POST['sdate_yy'])) {
die('ERROR: Invalid start date/time');
}
if (!checkdate($_POST['sdate_mm'], $_POST['sdate_dd'], $_POST['sdate_yy'])) {
die('ERROR: Invalid start date/time');
}
if (($_POST['sdate_hh']) < ($_POST['edate_hh'])){
die('ERROR: Hora de fin incorrecta');
}
$horas_inicio = $_POST['hora_inicio'];
list ($sdate_hh, $sdate_ii) = split('[:]', $horas_inicio);
$horas_fin = $_POST['hora_fin'];
list ($edate_hh, $edate_ii) = split('[:]', $horas_fin);
$title = htmlentities($title);
$start = date(DATE_ATOM, mktime($sdate_hh,$sdate_ii,
0, $_POST['sdate_mm'], $_POST['sdate_dd'], $_POST['sdate_yy']));
$end = date(DATE_ATOM, mktime($edate_hh, $edate_ii,
0, $_POST['sdate_mm'], $_POST['sdate_dd'], $_POST['sdate_yy']));
// construct event object
// save to server
try {
$event = $gcal->newEventEntry();
$event->title = $gcal->newTitle($title);
$event->where = array($gcal->newWhere($where));
$event->content = $gcal->newContent($description);
$when = $gcal->newWhen();
$when->startTime = $start;
$when->endTime = $end;
$event->when = array($when);
$gcal->insertEvent($event);
} catch (Zend_Gdata_App_Exception $e) {
echo "Error: " . $e->getResponse();
}
echo 'CITA CREADA!</br>';
echo "<form method=\"post\" action=\"calendar.php\">";
$user = $_POST['email']; $pass = $_POST['pass'];
echo "<input name=\"email\" type=\"hidden\" value=".$user."\"/>";
echo "<input name=\"pass\" type=\"hidden\" value=".$pass."\"/>";
echo "<input type=\"submit\" value=\"INTRODUCIR MAS CITAS\" />";
echo "</form>";
echo '<a href="https://www.google.com/calendar" target="_blank">Acceder al Calendario</a>';
}
?>
这是我的代码,通过这个,我插入了日历的所有事件,如何修改以使用谷歌日历 v3 键?
提前谢谢,对不起我的英语。
【问题讨论】:
标签: php api zend-framework google-api google-calendar-api