-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathopenapi.txt
1237 lines (888 loc) · 33.6 KB
/
openapi.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
[TOC]
# Gizwits Open API
## 简介
机智云 Open API 主要帮助开发者通过 HTTP 的方式维护用户、用户与设备之间的绑定关系,以及获取设备数据、发送控制指令给设备。
调用 API 需要获取 appid,product_key 和 token。appid 和 product_key 可以在产品信息页面获取到,token 通过用户注册和登录获取到。
下文中的参数统一用 {appid} 来表示,请将你自己的 appid 整个替换掉 {appid} (包括大括号)。
## 访问地址
http://api.gizwits.com
## SDK
* python sdk: https://github.com/gizwits/gservice_sdk_py
## 用户信息 [/app/users]
### 创建匿名用户 [POST]
如果您想让您的用户不需要显示注册和登录就能使用机智云的功能,就可以通过匿名注册的方式来为该用户创建一个匿名用户。phone_id 可以是手机的唯一识别码。
或者您已经有了自己的用户系统,不希望用户再次注册一次机智云帐号,您也可以使用该接口,为您的每一个用户创建一个对应的机智云匿名帐号。这时,phone_id 可以是用户在您的系统中的唯一识别码。如在与微信应用做对接时,phone_id 可以设置成微信用户的 openid。
+ Request (application/json)
+ Header
X-Gizwits-Application-Id: {appid}
+ Body
{
"phone_id": "apiary"
}
+ Response 201 (application/json)
+ Body
{
"uid": "akkdlfeiow",
"token": "akdlfkad",
"expire_at": 13894002020
}
+ 请求示例
curl --include \
--request POST \
--header "Content-Type: application/json" \
--header "X-Gizwits-Application-Id: {appid}" \
--data-binary "{
\"phone_id\": \"apiary\"
}" \
'http://api.gizwits.com/app/users'
### 使用用户名和密码创建用户 [POST]
+ Request (application/json)
+ Header
X-Gizwits-Application-Id: {appid}
+ Body
{
"username": "bob",
"password": "123456"
}
+ Response 201 (application/json)
+ Body
{
"uid": "akkdlfeiow",
"token": "akdlfkad",
"expire_at": 13894002020
}
+ 请求示例
curl --include \
--request POST \
--header "Content-Type: application/json" \
--header "X-Gizwits-Application-Id: {appid}" \
--data-binary "{
\"username\": \"bob\",
\"password\": \"123456\"
}" \
'http://api.gizwits.com/app/users'
### 使用邮箱创建用户 [POST]
用户通过邮箱注册机智云帐号,注册成功后会收到一封邮件通知。
+ Request (application/json)
+ Header
X-Gizwits-Application-Id: {appid}
+ Body
{
"email": "[email protected]",
"password": "123456"
}
+ Response 201 (application/json)
+ Body
{
"uid": "akkdlfeiow",
"token": "akdlfkad",
"expire_at": 13894002020
}
+ 请求示例
curl --include \
--request POST \
--header "Content-Type: application/json" \
--header "X-Gizwits-Application-Id: {appid}" \
--data-binary "{
\"email\": \"[email protected]\",
\"password\": \"123456\"
}" \
'http://api.gizwits.com/app/users'
### 使用手机号创建用户 [POST]
如果希望用户使用手机号注册机智云帐号,机智云提供短信验证码接口,您需要先调用获取验证码接口获取验证码,然后再进行注册。
+ Request (application/json)
+ Header
X-Gizwits-Application-Id: {appid}
+ Body
{
"phone": "123456",
"password": "123456",
"code": "abc"
}
+ Response 201 (application/json)
+ Body
{
"uid": "akkdlfeiow",
"token": "akdlfkad",
"expire_at": 13894002020
}
+ 请求示例
curl --include \
--request POST \
--header "Content-Type: application/json" \
--header "X-Gizwits-Application-Id: {appid}" \
--data-binary "{
\"phone\": \"123456\",
\"password\": \"123456\",
\"code\": \"abc\"
}" \
'http://api.gizwits.com/app/users'
### 使用第三方账号(百度/新浪/QQ)创建用户 [POST]
机智云目前支持使用百度、新浪和QQ创建用户,但是需要您在客户端实现 OAuth 授权,获得用户的 uid 和 token,机智云会验证 uid 和 token 的合法性,验证通过就会创建一个机智云帐号。
#### 关于 QQ 登录
使用 QQ 登录,需要提供您的机智云 APP ID 和 QQ 应用 APP ID 发送给我们的客服,我们客服将会在后台将二者进行关联。
手机客户端使用 QQ SDK 获取到用户的 openid 和 access_token,将 openid 和 access_token 作为 uid 和 token POST 到该接口:
{
"authData": {
"src": "qq",
"uid": opendid,
"token": access_token
}
}
+ Request (application/json)
+ Header
X-Gizwits-Application-Id: {appid}
+ Body
{
"authData": {
"src": "baidu|sina|qq",
"uid": "2346677",
"token":"pnktnjyb996sj4p156gjtp4im"
}
}
+ Response 201 (application/json)
+ Body
{
"uid": "akkdlfeiow",
"token": "akdlfkad",
"expire_at": 13894002020
}
+ 请求示例
curl --include \
--request POST \
--header "Content-Type: application/json" \
--header "X-Gizwits-Application-Id: {appid}" \
--data-binary "{
\"authData\": {
\"src\": \"baidu\",
\"uid\": \"2346677\",
\"token\":\"pnktnjyb996sj4p156gjtp4im\"
}
}" \
'http://api.gizwits.com/app/users'
### 匿名用户设置用户名和密码 [PUT]
假设您的机智云应用帮用户创建了一个匿名用户,他不需要注册就可以体验您的应用,并且绑定了设备,他体验满意之后,希望有一个自己的机智云帐号,但是又不想重复绑定设备。这时您可以调用该接口,为匿名用户设置用户名和密码,这样他就不再是一个匿名用户了。
+ Request (application/json)
+ Header
X-Gizwits-Application-Id: {appid}
X-Gizwits-User-token: {token}
+ Body
{
"username": "bob",
"password": "abda2"
}
+ Response 200 (application/json)
+ Body
{
"updatedAt": "2011-11-07T21:25:10.623Z"
}
+ 请求示例
curl --include \
--request PUT \
--header "Content-Type: application/json" \
--header "X-Gizwits-Application-Id: {appid}" \
--header "X-Gizwits-User-token: {token}" \
--data-binary "{
\"username\": \"bob\",
\"password\": \"abda2\"
}" \
'http://api.gizwits.com/app/users'
### 匿名用户设置手机号和密码 [PUT]
与匿名用户设置用户名和密码类似,该接口可以为匿名用户设置手机号和密码,但是需要先调用一次获取短信验证码的接口。
+ Request (application/json)
+ Header
X-Gizwits-Application-Id: {appid}
X-Gizwits-User-token: {token}
+ Body
{
"phone": "1328830223",
"password": "123456",
"code": "123"
}
+ Response 200 (application/json)
+ Body
{
"updatedAt": "2011-11-07T21:25:10.623Z"
}
+ 请求示例
curl --include \
--request PUT \
--header "Content-Type: application/json" \
--header "X-Gizwits-Application-Id: {appid}" \
--header "X-Gizwits-User-token: {token}" \
--data-binary "{
\"phone\": \"1328830223\",
\"password\": \"123456\",
\"code\": \"123\"
}" \
'http://api.gizwits.com/app/users'
### 修改密码 [PUT]
+ Request (application/json)
+ Header
X-Gizwits-Application-Id: {appid}
X-Gizwits-User-token: {token}
+ Body
{
"old_pwd": "123456",
"new_pwd": "123456"
}
+ Response 200 (application/json)
+ Body
{
"updatedAt": "2011-11-07T21:25:10.623Z"
}
+ 请求示例
curl --include \
--request PUT \
--header "Content-Type: application/json" \
--header "X-Gizwits-Application-Id: {appid}" \
--header "X-Gizwits-User-token: {token}" \
--data-binary "{
\"old_pwd\": \"123456\",
\"new_pwd\": \"123456\"
}" \
'http://api.gizwits.com/app/users'
### 修改 email [PUT]
+ Request (application/json)
+ Header
X-Gizwits-Application-Id: {appid}
X-Gizwits-User-token: {token}
+ Body
{
"email": "[email protected]",
}
+ Response 200 (application/json)
+ Body
{
"updatedAt": "2011-11-07T21:25:10.623Z"
}
+ 请求示例
curl --include \
--request PUT \
--header "Content-Type: application/json" \
--header "X-Gizwits-Application-Id: {appid}" \
--header "X-Gizwits-User-token: {token}" \
--data-binary "{
\"email\": \"[email protected]\"
}" \
'http://api.gizwits.com/app/users'
### 修改手机号 [PUT]
修改手机号需要先调用一次获取短信验证码的接口,给新手机号发送一条短信验证码。
+ Request (application/json)
+ Header
X-Gizwits-Application-Id: {appid}
X-Gizwits-User-token: {token}
+ Body
{
"phone": "1328830223",
"code": "abc"
}
+ Response 200 (application/json)
+ Body
{
"updatedAt": "2011-11-07T21:25:10.623Z"
}
+ 请求示例
curl --include \
--request PUT \
--header "Content-Type: application/json" \
--header "X-Gizwits-Application-Id: {appid}" \
--header "X-Gizwits-User-token: {token}" \
--data-binary "{
\"phone\": \"1328830223\",
\"code\": \"abc\"
}" \
'http://api.gizwits.com/app/users'
## 用户登录 [/app/login]
可以使用用户名/邮箱/手机号登录,一律填写到 username 字段。
### 用户登录 [POST]
+ Request (application/json)
+ Header
X-Gizwits-Application-Id: {appid}
+ Body
{
"username": "bob",
"password": "123456"
}
+ Response 200 (application/json)
+ Body
{
"uid": "akkdlfeiow",
"token": "akdlfkad",
"expire_at": 13894002020
}
+ 请求示例
curl --include \
--request POST \
--header "Content-Type: application/json" \
--header "X-Gizwits-Application-Id: {appid}" \
--data-binary "{
\"username\": \"bob\",
\"password\": \"123456\"
}" \
'http://api.gizwits.com/app/login'
## 获取 App Token [/app/request_token]
### 获取 App Token [POST]
* 请使用 *https* 调用本接口
* signature 的算法: signature = MD5(appid+appsecret) 32位小写
+ Request (application/json)
+ Header
X-Gizwits-Application-Id: {appid}
X-Gizwits-Application-Auth: {signature}
+ Response 200 (application/json)
+ Body
{
"token": "XxXXXxxxx",
"expired_at": 123333333,
}
+ 请求示例
curl --include \
--insecure \
--request POST \
--header "Content-Type: application/json" \
--header "X-Gizwits-Application-Id: {appid}" \
--header "X-Gizwits-Application-Auth: {signature}" \
'https://api.gizwits.com/app/request_token'
## 图片验证码 [/app/verify/codes]
### 获取图片验证码 [GET]
+ Request (application/json)
+ Header
X-Gizwits-Application-Id: {appid}
X-Gizwits-Application-Token: {token}
+ Response 200 (application/json)
+ Body
{
"captcha_url": "http://xxxxx",
"captcha_id": "XXXXXXXxxxxxxx",
}
+ 请求示例
curl --include \
--header "Content-Type: application/json" \
--header "X-Gizwits-Application-Id: {appid}" \
--header "X-Gizwits-Application-Token: {token}" \
'http://api.gizwits.com/app/verify/codes'
### 发送手机短信验证码 [POST]
+ Request (application/json)
+ Header
X-Gizwits-Application-Id: {appid}
X-Gizwits-Application-Token: {token}
+ Body
{
"captcha_id": "XXXXXXXxxxxxxx",
"captcha_code": "123123",
"phone": "123123123"
}
+ Response 201 (application/json)
+ 请求示例
Try curl --include \
--request POST \
--header "Content-Type: application/json" \
--header "X-Gizwits-Application-Id: {appid}" \
--header "X-Gizwits-Application-Token: {token}" \
--data-binary "{
\"captcha_id\": \"XXXXXXXxxxxxxx\",
\"captcha_code\": \"123123\",
\"phone\": \"123123123\"
}" \
'http://api.gizwits.com/app/verify/codes'
### 校验短信验证码 [PUT]
+ Request (application/json)
+ Header
X-Gizwits-Application-Id: {appid}
X-Gizwits-Application-Token: {token}
+ Body
{
"sms_code": "123xx",
"phone": "123123123"
}
+ Response 200 (application/json)
+ 请求示例
curl --include \
--request PUT \
--header "Content-Type: application/json" \
--header "X-Gizwits-Application-Id: {appid}" \
--header "X-Gizwits-Application-Token: {token}" \
--data-binary "{
\"sms_code\": \"123xx\",
\"phone\": \"123123123\"
}" \
'http://api.gizwits.com/app/verify/codes'
## 重置密码 [/app/reset_password]
### 使用邮箱重置密码 [POST]
请求成功后用户会收到一封重置密码的邮件, 用户根据邮件的链接进行密码重置。
+ Request (application/json)
+ Header
X-Gizwits-Application-Id: {appid}
+ Body
{
"email": "[email protected]"
}
+ Response 200 (application/json)
+ 请求示例
curl --include \
--request POST \
--header "Content-Type: application/json" \
--header "X-Gizwits-Application-Id: {appid}" \
--data-binary "{
\"email\": \"[email protected]\"
}" \
'http://api.gizwits.com/app/reset_password'
### 使用手机号重置密码 [POST]
使用手机号重置密码需要先调用一次获取短信验证码的接口。
+ Request (application/json)
+ Header
X-Gizwits-Application-Id: {appid}
+ Body
{
"phone": "13232433",
"code": "13232',
"new_pwd": "1323200"
}
+ Response 200 (application/json)
+ 请求示例
curl --include \
--request POST \
--header "Content-Type: application/json" \
--header "X-Gizwits-Application-Id: {appid}" \
--data-binary "{
\"phone\": \"13232433\",
\"code\": \"13232\',
\"new_pwd\": \"1323200\"
}" \
'http://api.gizwits.com/app/reset_password'
## 获取设备最近上传数据 [/app/devdata/{did}/latest]
### 获取设备最近上传数据点 [GET]
获取设备最近一次上传的数据,包含所有数据点的键值对。
+ 参数列表
+ did (required, string, `gdGn7PzAYf4VrhnVag5x8D`)
+ Request (application/json)
+ Header
X-Gizwits-Application-Id: {appid}
+ Response 200 (application/json)
+ Body
{
"did": "gdGn7PzAYf4VrhnVag5x8D",
"updated_at": 148293984328,
"attr": {
"temp": 10,
"humi": 20
}
}
+ 请求示例
curl --include \
--header "Content-Type: application/json" \
--header "X-Gizwits-Application-Id: {appid}" \
'http://api.gizwits.com/app/devdata/gdGn7PzAYf4VrhnVag5x8D/latest'
## 绑定设备 [/app/bind_mac]
### 绑定设备 [POST]
X-Gizwits-Timestamp 与服务器相差不能超过 5 分钟
X-Gizwits-Signature = MD5(product_secret + X-Gizwits-Timestamp).lower()
+ Request (application/json)
+ Header
X-Gizwits-Application-Id: {appid}
X-Gizwits-User-token: {token}
X-Gizwits-Timestamp: {req_ts}
X-Gizwits-Signature: {sig}
+ Body
{
"product_key": "xxx",
"mac": "xxx",
"remark": "xxx",
"dev_alias": "xxx"
}
+ Response 201 (application/json)
+ 请求示例
curl --include \
--request POST \
--header "Content-Type: application/json" \
--header "X-Gizwits-Application-Id: {appid}" \
--header "X-Gizwits-User-token: {token}" \
--header "X-Gizwits-Timestamp: {req_ts}" \
--header "X-Gizwits-Signature: {sig}" \
--data-binary "{
\"product_key\": \"xxx\",
\"mac\": \"xxx\",
\"remark\": \"xxx\",
\"dev_alias\": \"xxx\"
}" \
'http://api.gizwits.com/app/bind_mac'
## 绑定关系 [/app/bindings]
### 获取绑定列表 [GET]
+ 参数列表
+ limit (optional, number, `20`)
+ skip (optional, number, `0`)
limit 和 skip 表示分页参数。limit 为一次性返回的最多条数,skip 为跳过多少条数据。
如每页 10 条数据,获取第一页数据:limit=10, skip=0;获取第二页数据:limit=10, skip=10.
+ Request (application/json)
+ Header
X-Gizwits-Application-Id: {appid}
X-Gizwits-User-token: {token}
+ Response 200 (application/json)
+ Body
{
"devices": [{
"product_key": "akdlfkad",
"did": "abcada",
"mac": "1122334455667788",
"is_online": false,
"passcode": "123456",
"host": "m2m.gizwits.com",
"port": 3128,
"remark": "",
"is_disabled": false,
"type": "normal",
"dev_alias": "dev1"
},{
"product_key": "akdlfkad",
"did": "abcada",
"mac": "1122334455667788",
"is_online": false,
"passcode": "123456",
"host": "m2m.gizwits.com",
"port": 3128,
"remark": "",
"is_disabled": false,
"type": "center_control",
"dev_alias": "dev2"
}]
}
+ 请求示例
curl --include \
--header "Content-Type: application/json" \
--header "X-Gizwits-Application-Id: {appid}" \
--header "X-Gizwits-User-token: {token}" \
'http://api.gizwits.com/app/bindings?show_disabled=1&limit=20&skip=0'
### 绑定设备: 通过 did + passcode [POST]
使用该接口适合知道 did 和 passcode 的情况。
dev_alias 设备别名,用于当前用户对该设备起一个别名,仅该用户可见。
remark 用于设置备注信息。
+ Request (application/json)
+ Header
X-Gizwits-Application-Id: {appid}
X-Gizwits-User-token: {token}
+ Body
{
"devices": [{
"did": "gdGn7PzAYf4VrhnVag5x8D",
"passcode": "gokit",
"remark": "",
"dev_alias": "my_dev"
}]
}
+ Response 200 (application/json)
{
"success": ['abc', 'add'],
"failed": ['adad', 'ee']
}
+ 请求示例
curl --include \
--request POST \
--header "Content-Type: application/json" \
--header "X-Gizwits-Application-Id: {appid}" \
--header "X-Gizwits-User-token: {token}" \
--data-binary "{
\"devices\": [{
\"did\": \"gdGn7PzAYf4VrhnVag5x8D\",
\"passcode\": \"gokit\",
\"remark\": \"\",
\"dev_alias\": \"\"
}]
}" \
'http://api.gizwits.com/app/bindings'
### 解除绑定 [DELETE]
+ Request (application/json)
+ Header
X-Gizwits-Application-Id: {appid}
X-Gizwits-User-token: {token}
+ Body
{
"devices": [{
"did": "gdGn7PzAYf4VrhnVag5x8D"
}]
}
+ Response 200 (application/json)
{
"success": ['abc', 'add'],
"failed": ['adad', 'ee']
}
+ 请求示例
curl --include \
--request DELETE \
--header "Content-Type: application/json" \
--header "X-Gizwits-Application-Id: {appid}" \
--header "X-Gizwits-User-token: {token}" \
--data-binary "{
\"devices\": [{
\"did\": \"gdGn7PzAYf4VrhnVag5x8D\"
}]
}" \
'http://api.gizwits.com/app/bindings'
## 远程控制设备 [/app/control/{did}]
远程控制设备可以通过两种方式,一种是设置数据点,一种是发送原始控制指令。
推荐使用设置数据点的方式,通过这种方式控制设备,系统内部自动会生成原始控制指令发送给设备,使用起来更简单。
+ 参数列表
+ did (required, string, `did`)
### 设置数据点 [POST]
* 只能设置可写类型的数据点
* bool 类型的数据点设置为 true/false
* enum 类型的数据点设置为枚举的字符串
* uint8/uint16/uint32 类型的数据点设置为数字
* binary 类型的数据设置为 hex 类型字符串,如发送一串十六进制数据 0x01, 0x02, 0x03, 就写成 "010203";
如果 binary 类型本身为字符串,如 "hello world!",需将字符串每个字符的 ASCII 转成十六进制再发送,本例为 "68656c6c6f20776f726c6421";
**注意 binary 类型定义了多少长度,就需要发多少长度的数据**。
+ Request (application/json)
+ Header
X-Gizwits-Application-Id: {appid}
X-Gizwits-User-token: {token}
+ Body
{
"attrs": {
"temp": 10
}
}
+ Response 200 (application/json)
+ Body
{}
+ Request (application/json)
+ Header
X-Gizwits-Application-Id: {appid}
X-Gizwits-User-token: {token}
+ Body
{
"attrs": {
"temp": 10,
"humi": 50
}
}
+ Response 200 (application/json)
+ Body
{}
+ 请求示例
curl --include \
--request POST \
--header "Content-Type: application/json" \
--header "X-Gizwits-Application-Id: {appid}" \
--header "X-Gizwits-User-token: {token}" \
--data-binary "{
\"attrs\": {
\"temp\": 10
}
}" \
'http://api.gizwits.com/app/control/did'
### 发送原始控制指令 [POST]
+ Request (application/json)
+ Header
X-Gizwits-Application-Id: {appid}
X-Gizwits-User-token: {token}
+ Body
{
"raw": [<byte>, <byte>, ...]
}
+ Response 200 (application/json)
+ Body
{}
+ 请求示例
curl --include \
--request POST \
--header "Content-Type: application/json" \
--header "X-Gizwits-Application-Id: {appid}" \
--header "X-Gizwits-User-token: {token}" \
--data-binary "{
\"raw\": [0, 1, 2, 3]
}" \
'http://api.gizwits.com/app/control/did'
## 定时任务 [/app/scheduler{?limit,skip}]