satagro / fieldclimate Goto Github PK
View Code? Open in Web Editor NEWA Python client for the Pessl Instruments GmbH RESTful API.
License: GNU Lesser General Public License v3.0
A Python client for the Pessl Instruments GmbH RESTful API.
License: GNU Lesser General Public License v3.0
good evening. i didnt manage to make javascript fetch data from the API.
any chance to make it work ?
For now , i got this code:
var pub_key = "xxx";
var priv_key = "yyy";
var dateStamp = "Fri, 03 Jan 2020 21:57:10 GMT";
var content = "GET"+"/user"+dateStamp+pub_key;
var hash = CryptoJS.HmacSHA256(content, priv_key);
//var hashInBase64 = CryptoJS.enc.Base64.stringify(hash);
var tmpstr=hash+"";
var authStr = "hmac " + pub_key +":" + tmpstr;
let API_LINK = "https://api.fieldclimate.com/v1/user";
console.log("=============");
console.log("hmac "+pub_key+":"+tmpstr);
fetch(API_LINK, {
method: "GET",
headers: {
"Accept":"application/json",
"Authorization":authStr
}
})
//response => response.ok ? response.json() : Promise.reject(response)
.then(response => {console.log(response)})
.then(data => {console.log(data)})
.catch( error => {console.log(error)})
But i get 401 response code :/
Czytam dokumentację API i jedno mnie mocno dziwi:
Oto podana przez nich przykładowa odpowiedź na zapytanie GET /user/licenses:
{
"models": {
"CROP": {
"STATION-ID": [
{
"from": "DATE-TIME",
"to": "DATE-TIME"
}
],
"STATION-ID": [
{
"from": "DATE-TIME",
"to": "DATE-TIME"
}
],...
},
"CROP": {
"STATION-ID": [
{
"from": "DATE-TIME",
"to": "DATE-TIME"
}
],
"STATION-ID": [
{
"from": "DATE-TIME",
"to": "DATE-TIME"
}
],...
},...
},
"Forecast": {
"STATION-ID": [
{
"from": "DATE-TIME",
"to": "DATE-TIME"
}
],
"STATION-ID": [
{
"from": "DATE-TIME",
"to": "DATE-TIME"
}
],...
}
}
Jeśli dobrze widzę, to klucz "CROP" jest zduplikowany. Czy to w ogóle jest poprawny JSON?
Jeśli takie odpowiedzi mogą przychodzić, to jak je obsłużyć?
Z tego, co rozumiem, to biblioteka winna po prostu zwrócić słownik Pythonowy powstający ze sparsowania JSON-a, tak? Ale przecież słownik nie może zawierać zduplikowanych kluczy?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.