Google日历小工具:如何从日历中点击的事件中获取UID

时间:2015-07-21 06:51:58

标签: javascript google-calendar-api google-gadget

这是一个侧栏小工具,可以监听事件点击并返回我的事件信息(More Info):

<Module>
  <ModulePrefs title="subscribeToEvents Test" height="200" author="me"
    <Optional feature="google.calendar-0.5.read"/>
</ModulePrefs>
  <Content type="html">
  <![CDATA[
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  "http://www.w3.org/TR/html4/strict.dtd">
<html>
<body>
   <div id="out">No event</div>

<script>

function subscribeEventsCallback(e) {

  var html = 'No event';
  if (e) {
    html = gadgets.json.stringify(e);
  }
  document.getElementById('out').innerHTML = gadgets.util.escapeString(html);
}

///https://www.google.com/calendar/b/1/render?gadgeturl=http://devblog.meeterapp.com/wp-content/uploads/2015/03/fess_subscribe_to_dates.xml#main_7
// The gadget containers request that we do NOT run any JS inline.
// Instead, register a callback handler.
gadgets.util.registerOnLoadHandler(function() {
  google.calendar.read.subscribeToEvents(subscribeEventsCallback);
});


function showEvent(){
    google.calendar.showEvent(localEevent.id);
}

</script>
</body>
</html>
  ]]></Content>
</Module>

问题是:Google返回给我的JSON有id但不是UID,

谷歌日历内部使用的唯一ID。

例如,如果用户点击Google日历上的某些活动,我会收回此JSON:

{
  "timezone": "Asia/Jerusalem",
  "startTime": {
    "year": 2015,
    "month": 7,
    "date": 6,
    "hour": 14,
    "minute": 0,
    "second": 0
  },
  "endTime": {
    "year": 2015,
    "month": 7,
    "date": 6,
    "hour": 15,
    "minute": 0,
    "second": 0
  },
  "title": "Testing",
  "location": "",
  "id": "bGxwb3VoZXJkcGYyY2NlaDluMW41dWRvNm9gc2hvdXN0aW5AbQ",
  "status": "invited",
  "color": "#DB7972",
  "palette": {
    "darkest": "#D06B64",
    "dark": "#924420",
    "medium": "#D06B64",
    "light": "#DB7972",
    "lightest": "#F0D0CE"
  },
  "attendees": [],
  "attendeeCount": 0,
  "calendar": {
    "email": "snaggs@gmail.com"
  },
  "creator": {
    "email": "snaggs@gmail.com"
  },
  "owner": {
    "email": "snaggs@gmail.com"
  },
  "accessLevel": "owner"
}

我们"id": "bGxwb3VoZXJkcGYyY2NlaDluMW41dWRvNm9gc2hvdXN0aW5AbQ",用于google.calendar.showEvent("bGxwb3VoZXJkcGYyY2NlaDluMW41dWRvNm9gc2hvdXN0aW5AbQ")

如何获取会议UID,例如llpouherdpf2cceh7n1n5udo6o@google.com

请帮忙,

0 个答案:

没有答案