[ 初投稿 ]
Google.Calendarを ローカルで利用する為の
Source.Generatorを 作った。
calenG ( TwilightBluesy )
幾つかの方法を比較したトコロ
この方法が一番 扱いやすいのでは と 思う。
cG20.sh or cG20.bat を
コマンドライン or Application から call 。
cG20.php
<?php
$apiKey = urlencode($_REQUEST['aKey']);
$cal_id = urlencode($_REQUEST['c_ID']);
$time_0 = $_REQUEST['dt_0'];
$time_1 = $_REQUEST['dt_1'];
$url0 = $_REQUEST['cURL'];
$url1 = "{$url0}{$cal_id}/events?";
$qryX = [
'key' => $apiKey,
'timeMin' => $time_0,
'timeMax' => $time_1,
'singleEvents' => 'true'
];
$resX = [];
$cont = file_get_contents($url1.http_build_query($qryX),true);
$arYo = ['日','月','火','水','木','金','土'];
$dlmt = "\t";
if($data = $cont){
$data = json_decode($data);
foreach($data->items as $row){
$dd = $row->start->date;
$dt = $row->start->dateTime;
$sm = $row->summary;
if($dd){
$dt = '00:00:00';
}elseif($dt){
$a0 = explode('T',$dt);
$a1 = explode('+',$a0[1]);
$dd = $a0[0];
$dt = $a1[0];
}
$yo = $arYo[date('w',strtotime($dd))];
$rX = $dd.$dlmt.$yo.$dlmt.$dt.$dlmt.$sm;
$resX[] = $rX;
}
}
sort($resX);
echo implode("\n",$resX);
?>
cG20.sh
#!/bin/bash
cd `dirname $0`
oSys=0
cPHP='https://twilight-bluesy.net/_utl/calenG-api/cG20.php'
cURL='https://www.googleapis.com/calendar/v3/calendars/'
aKey='xxxxxx'
c_ID='ja.japanese#holiday@group.v.calendar.google.com'
dt_0='2024-01-01'
dt_1='2024-12-31'
memo='hoge'
deno cache --reload ./test20.ts
deno run --allow-net ./test20.ts ${oSys} ${cPHP} ${cURL} ${aKey} ${c_ID} ${dt_0} ${dt_1} ${memo}
cG20.bat
@echo off
cd %~dp0
set oSys=9999
set cPHP=https://twilight-bluesy.net/_utl/calenG-api/cG20.php
set cURL=https://www.googleapis.com/calendar/v3/calendars/
set aKey=xxxxxx
set c_ID=ja.japanese#holiday@group.v.calendar.google.com
set dt_0=2024-01-01
set dt_1=2024-12-31
set memo=hoge
deno cache --reload ./test20.ts
deno run --allow-net ./test20.ts %oSys% %cPHP% %cURL% %aKey% %c_ID% %dt_0% %dt_1% %memo%
test20.ts
//==============================================================================
const oSys = Number(Deno.args[0]);
const cPHP = Deno.args[1];
const cURL = encodeURIComponent(Deno.args[2]);
const aKey = encodeURIComponent(Deno.args[3]);
const c_ID = encodeURIComponent(Deno.args[4]);
const dt_0 = Deno.args[5] + 'T00:00:00Z';
const dt_1 = Deno.args[6] + 'T00:00:00Z';
const memo = Deno.args[7];
//----------------------------------------------------------
const xURL = `${cPHP}\?cURL=${cURL}\&aKey=${aKey}\&c_ID=${c_ID}\&dt_0=${dt_0}\&dt_1=${dt_1}`;
//----------------------------------------------------------
const res = await fetch(xURL);
const buf = await res.arrayBuffer();
const bd0 = new Uint8Array(buf);
const bd1 = new TextDecoder().decode(bd0);
//----------------------------------------------------------
opData(bd1);
//==============================================================================
function opData(bd1){
//------------------------------
const ar0 = bd1.split('\n');
//------------------------------
console.log(ar0);
//------------------------------
// ar0.forEach((rec,ix)=>{
// const ar1 = rec.split('\t');
// console.log(ar1);
// console.log(`${ix}\t${rec}`);
// });
//------------------------------
}
//==============================================================================
PHPファイルは 今んトコロ公開しているが
この先どうなるかは 未定。