Bonjour,
J’ai entrepris de récupérer l’agenda de mon fils sur jeedom. Le but ultime est d’avoir l’heure du réveil qui se calcul en fonction du premier cours ![]()
J’ai identifé l’API et la syntaxe pour récupérer l’agenda. Dans le meilleur des mondes cela fonctionne.
J’ai le fichier JSON
Par exemple
{
"week": {
"lundi": [
{
"date": "28/09/2020",
"subject": "xxxxxx",
"start": "13:00",
"end": "17:00",
"professor": "yyyyy",
"room": "N213(HEP Nantes)",
"weekday": "lundi",
"bts": false,
"presence": true
},
{
"date": "28/09/2020",
"subject": "xxxxxx",
"start": "08:00",
"end": "12:00",
"professor": "yyyy",
"room": "N213(HEP Nantes)",
"weekday": "lundi",
"bts": false,
"presence": true
}
],
Ce qui donne
Et j’ai trouvé quelques tuto pour commencer le script
// Step 1: Recuperation du contenu du fichier
$api = "https://api-calendar.calendz.app/v1/week/:10-02-2020?firstname=xxx&lastname=xxxx";
$json = file_get_contents($api);
$scenario->setlog('-----RAW----------');
$scenario->setlog($json);
$scenario->setlog('');
// Step 2: Decodage du JSON et recuperation des infos souhaitees
$jsonData = json_decode($json,true);
$scenario->setlog('-------DECODE----------');
$scenario->setlog($jsonData);
$scenario->setlog('');
if(is_array($jsonData)){
$scenario->setlog('---IMPORT SUCCESS----');
$scenario->setlog('');
foreach ($jsonData['week'] as $jsonKey) {
$scenario->setlog('---FOUND WEEK----');
}
}
Les logs
2020-12-29 23:40:24][SCENARIO] Start : Scenario lance manuellement.
[2020-12-29 23:40:25][SCENARIO] Exécution du sous-élément de type [action] : code
[2020-12-29 23:40:25][SCENARIO] Exécution d'un bloc code
[2020-12-29 23:40:25][SCENARIO] -----RAW----------
[2020-12-29 23:40:25][SCENARIO] {"week":{"lundi":[{"date":"28/09/2020","subject":"xxxxxxxxxxxxxxxxxxx"bts":false,"presence":true}]},"weekNumber":40,"scrappedToday":"true"}
[2020-12-29 23:40:25][SCENARIO]
[2020-12-29 23:40:25][SCENARIO] -------DECODE----------
[2020-12-29 23:40:25][SCENARIO] Array
[2020-12-29 23:40:25][SCENARIO]
[2020-12-29 23:40:25][SCENARIO] ---IMPORT SUCCESS----
[2020-12-29 23:40:25][SCENARIO]
[2020-12-29 23:40:25][SCENARIO] ---FOUND WEEK----
[2020-12-29 23:40:25][SCENARIO] ---FOUND WEEK----
[2020-12-29 23:40:25][SCENARIO] ---FOUND WEEK----
[2020-12-29 23:40:25][SCENARIO] ---FOUND WEEK----
[2020-12-29 23:40:25][SCENARIO] ---FOUND WEEK----
[2020-12-29 23:40:25][SCENARIO] Fin correcte du scénario
Comment récuperer un jour complet?
Merci d’avance de votre support


mes excuses, des explications 