· 4 years ago · Jun 18, 2021, 09:22 AM
1function getBinotel () {
2var ss = SpreadsheetApp.getActiveSpreadsheet(); // Таблица
3var sheet = SpreadsheetApp.getActiveSheet(); // Лист
4 var url = "https://api.binotel.com/api/4.0/stats/all-incoming-calls-since.json" // API Точка входа
5var data = {
6 "key": "f4fac7-b43f5e4",
7 "secret": "83cb5e-b82bad-a2cd40-73b7a5-ee08b107",
8 "timestamp":"1624007412"
9 }
10
11 var options = { // Опции запроса к API
12 'method' : 'post', // Тип запроса
13 'payload' : JSON.stringify(data)
14}
15
16
17let response = UrlFetchApp.fetch(url, options);
18let json = JSON.parse(response.getContentText())
19
20const dataJson = json
21
22const arr = [];
23
24for (number in dataJson.callDetails) {
25 var numdata = dataJson.callDetails[number]
26 for (item in numdata) {
27
28 console.log(item, numdata[item])
29 // нужно добавить в массив по колонкам
30 }
31}
32
33
34Logger.log(arr);
35
36const sh = SpreadsheetApp.getActive().getSheetByName('binotel');
37
38
39}
40
41