WIFIモジュールに接続されたSESAME4(スマートロック)に
ブラウザ(JAVASCRIPT)でアクセスし状態情報を取得するサンプルコードです。
header付きでクエリを投げる必要があった為、手っ取り早く
axiosというJAVASCRIPTのライブラリを利用しました。
<html>
<head>
<title>Javascript でsesameの状態を所得する</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script >
function init()
{
var uuid = "YOUR_UUID";
var api_key ="YOUR_API_KEY";
axios.get("https://app.candyhouse.co/api/sesame2/" + uuid, { headers: { "X-API-KEY" : api_key} })
.then(function (response) {
// handle success
alert(JSON.stringify(response.data));
})
}
</script>
</head>
<body>
<input type="button" value="sesameの状態取得" onclick="init()">
</body>
</html>
最近のコメント