不死心的過客,一定覺得Apps Script怎麼可能做不到呢...
既然是加密的eid...那可能可以解密
透過Apps Script的Utilities類別,我們將上篇的htmlLink後面的eid欄位取出來分析
因為比較像Base64...我們採用Base64來做解密...(可以參考:https://developers.google.com/apps-script/reference/utilities/utilities#base64Decode(String,Charset))
下面試測試function...
function test123(){
var o = 'ZTc0Mjk4OHVicHRrdHNjM.....RhYy5jb20udHc';
Logger.log(o);
var e = Utilities.base64Decode(o, Utilities.Charset.UTF_8);
Logger.log(Utilities.newBlob(e).getDataAsString());
}
執行後,果如預期... 分析如下:
透過分析,我們可以新增build htmlLink的function如下:
function getHtmlLink(id, user) {
var ori = id.split('@')[0] + ' ' + user;
var enc = Utilities.base64Encode(ori, Utilities.Charset.UTF_8);
}
然後call法可以向下面這樣...
function getEvents(calId, startTime, endTime) {
if(!calId || !startTime || !endTime)
return {"error":"parameter error"};
CalendarApp.subscribeToCalendar(calId);
var cal = CalendarApp.getCalendarById(calId);
var event = cal.getEvents(new Date(startTime), new Date(endTime));
var data = new Array();
for(var i = 0 ; i < event.length; i++) {
var out = {};
var ev = event[i];
out["id"] = ev.getId();
out["uri"] = getHtmlLink(ev.getId(), calId);
out["title"] = ev.getTitle();
out["startTime"] = ev.getStartTime();
out["endTime"] = ev.getEndTime();
data.push(out);
}
return data;
}
讚不讚∼
留言
張貼留言