0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

myThingsAdvent Calendar 2016

Day 16

meshbluのツール

Last updated at Posted at 2016-12-17

#概要
mythingsのmeshbluのapiを叩く、ツールズです。
jqueryのajaxを使います。
#生存確認

$.ajax({
	type: 'get',
	url: 'http://meshblu url/status',
	success: function(json) {
		echo(dump(json));
	},
	error: function(XMLHttpRequest, textStatus, errorThrown) {
		alert(textStatus);
	},
});

#デバイスリスト

$.ajax({
	type : 'get',
	url : 'http://meshblu url/devices',
	headers : {
		'meshblu_auth_uuid': 'trigger-1 uuid',
		'meshblu_auth_token': 'trigger-1 token'
	},
	success : function(json) {
		echo(dump(json));
	},
	error: function(XMLHttpRequest, textStatus, errorThrown) {
		alert(textStatus);
	},
});

#発火

$.ajax({
    type: 'post',
    url: 'http://mesh blu/data/trigger-1 uuid',
    data: {
        "text1": "300"
    },
    headers: {
        'meshblu_auth_uuid': 'trigger-1 uuid',
        'meshblu_auth_token': 'trigger-1 token'
    },
    success: function(json) {
        echo(dump(json));
    },
    error: function(XMLHttpRequest, textStatus, errorThrown) {
        alert(textStatus);
    }
});

#発火の確認

$.ajax({
    type : 'get',
    url : 'http://meshblu url/data/trigger-1 uuid?start=2016-12-14T10:25:01.766Z&finish=2016-12-24T10:40:01.766Z&limit=10',
    headers : {
        'meshblu_auth_uuid': 'owner uuid',
        'meshblu_auth_token': 'owner token'
    },
    success : function(json) {
        echo(dump(json));
    },
    error: function(XMLHttpRequest, textStatus, errorThrown) {
        alert(textStatus);
    },
});
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?