WEB/APP/微信开发接口
主要由HTTP及UDP包接口组成

APP开发介绍:
APP接口详细请下载文档阅读,主要由两部分组成

1、HTTP请求,涉及注册,登录,验证,获取设备信息,传感器信息,控制设备

 

其实HTTP开发难度小,而且适合WEB/微信/app开发,如果你在你的服务器的网页或者微信公众号要控制连接在Fuhome服务器上的设备,需要通过curl方式模拟http请求接口即可实现。

 

客户端开发需要用到开发者openid,其用途非常广泛,可以自己设计客户端 ,登录个人中心,会看到申请接口


协议采用ASCII 字符,汉字编码:UTF-8


username:用户名
userid:用户的10位数字id,登录个人中心左侧栏目显示与用户名一一对应
psw:用户密码md5加密的32位小写密码
openid:开发者拥有的开发密钥,登陆 www.fuhome.net 即可申请只需1.99元

 

HTTP基础接口(仅此一条即可开发APP等客户端控制设备)

HTTP发送对设备的控制命令(发送命令字符串)
URL:http://fuhome.net/api/dev/?openid=d32ffbe0ce1e7dccf15483d978365a40&devid=1287369152&comstring=open
请求方式:GET/POST

 直接用浏览器即可控制,超简单,也可以用来开发自己的电脑软件,手机APP

正确服务器回复:
{

"dis":"r=1",

"log":"ok",

"devid":"1287369152",

"comstring":"open",

"comback":"OK",

"time":"2018-07-28 12:07:13"

}
错误回复:
{
"dis":"w=1",
"log":"wrong"
}
devid:设备10位ID

错误:设备id、密码等细信息错误


HTTP进阶部分

GET/POST调试工具测试:http://www.atool.org/httptest.php
用户登录 增加设备,获取用户的设备列表,
获取、增加菜单,传感器列表
控制设备接口
单个或批量获取传感器值


2、用户登录
URL:http://fuhome.net/api/sblist/
请求方式:GET/POST(通用)
openid=d32ffbe0ce1e7dccf15483d978365a40&username=lovelife
&psw=4297f44b13955235245b2497399d7a93&f=2&time=1865423652

http://fuhome.net/api/sblist/
请求方式:GET/POST(微信用)
openid=d32ffbe0ce1e7dccf15483d978365a40&username=fromusername&f=2&time=1865423652

正确服务器回复:
{
"dis":"f=2",
"log":"ok",
"userid":"1020398130"
}
错误回复:
{
"dis":"f=2",
"log":"wrong"
}
3、添加认证设备
URL:http://fuhome.net/api/sblist/
请求方式:GET/POST
openid=d32ffbe0ce1e7dccf15483d978365a40&userid=1020398130&psw=4297f44b13955235245b2497399d7a93&
sbstr=12345678abcedf0a&sbname=办公室的灯&f=3&time=1865423652

正确服务器回复:
{
"dis":"f=3",
"log":"ok",
"sbid":"1287369152",
"sbmm":"adf28d9b7a8d08b5",
"sbname":"办公室的灯"
}
错误回复:
{
"dis":"f=3",
"log":"wrong"
}
sbId:设备10位id
SbMm:设备16位加密密码
Sbname:设备名字
错误:串号错误或已经激活


4、增加普通DIY设备
URL:http://fuhome.net/api/sblist/
请求方式:GET/POST
openid=d32ffbe0ce1e7dccf15483d978365a40&userid=1020398130
&psw=4297f44b13955235245b2497399d7a93&sbname=办公室的灯&sjm=123456&f=4&time=1865423652

正确服务器回复:
{
"dis":"f=4",
"log":"ok",
"sbid":"1287369152",
"sbmm":"adf28d9b7a8d08b5",
"sbname":"办公室的灯"
}
错误回复:
{
"dis":"f=4",
"log":"wrong"
}
Sbname:设备名字
Sjm:设备明文密码,位数6-16,系统会自动加密生成16位加密密码
错误:资格数不够用


5、请求获取用户的设备列表
URL:http://fuhome.net/api/sblist/
请求方式:GET/POST
openid=d32ffbe0ce1e7dccf15483d978365a40&userid=1020398130
&psw=4297f44b13955235245b2497399d7a93&f=5&time=1865423652

http://fuhome.net/api/sblist/
请求方式:GET/POST(微信用)
openid=d32ffbe0ce1e7dccf15483d978365a40& userid=1020398130&username=fromusername&f=5&time=1865423652

正确服务器回复:
{
"dis":"f=5",
"log":"ok",
"userid":"1023950720",
"c":"003",
"sb":[
{"shuxing":"00a","id":"10","sbid":"1234567891","sbname":"电饭锅","sbtime":"2016-05-22 15:00:07","sbadd":"深圳市","statename":"状态","statevalue":"open","imgurl":"3.jpg"},
{"shuxing":"00a","id":"99","sbid":"1234567890","sbname":"电风扇","sbtime":"2016-05-22 15:00:07","sbadd":"深圳市","statename":"现状","statevalue":"open","imgurl":"5.png"},
{"shuxing":"00a","id":"301","sbid":"1234567892","sbname":"热得快","sbtime":"2016-05-22 15:00:07","sbadd":"深圳市","statename":"在线 ON","statevalue":"烧水中","imgurl":"10.jpg"}
]
}
错误回复:
{
"dis":"f=5",
"log":"wrong"
}

PS. C:设备总数
Shuxing:暂无用 Id:小id与ID一 一对应 Sbid:ID ,Sbname:设备名字,sbtime:最新活动时间 sbadd:设备所在地址
Statename:状态量名字 Statevalue:状态量(见设备端协议,心跳包中所附带信息)
Imgurl: 设备的大头贴,完整路径:http://fuhome.net/home/image/pic/10.jpg


16、请求获得权限的设备列表
URL:http://fuhome.net/api/sblist/
请求方式:GET/POST
openid=d32ffbe0ce1e7dccf15483d978365a40&userid=1020398130
&psw=4297f44b13955235245b2497399d7a93&f=16&time=1865423652

http://fuhome.net/api/sblist/
请求方式:GET/POST(微信用)
openid=d32ffbe0ce1e7dccf15483d978365a40&userid=1020398130&username=fromusername&f=16&time=1865423652

正确服务器回复:
{
"dis":"f=16",
"log":"ok",
"userid":"1023950720",
"c":"003",
"sb":[
{"shuxing":"00a","id":"10","sbid":"1234567891","sbname":"电饭锅","sbtime":"2016-05-22 15:00:07","sbadd":"深圳市","statename":"状态","statevalue":"open","imgurl":"3.jpg"},
{"shuxing":"00a","id":"99","sbid":"1234567890","sbname":"电风扇","sbtime":"2016-05-22 15:00:07","sbadd":"深圳市","statename":"现状","statevalue":"open","imgurl":"5.png"},
{"shuxing":"00a","id":"301","sbid":"1234567892","sbname":"热得快","sbtime":"2016-05-22 15:00:07","sbadd":"深圳市","statename":"在线 ON","statevalue":"烧水中","imgurl":"10.jpg"}
]
}

6、请求获取设备拥有的自定义菜单列表,传感器列表
URL:http://fuhome.net/api/sblist/
请求方式:GET/POST
openid=d32ffbe0ce1e7dccf15483d978365a40&userid=1020398130
&psw=4297f44b13955235245b2497399d7a93&f=6&id=99&time=1865423652
id:上一条返回的信息中的id(99是电风扇的id)

正确服务器回复:
{
"dis":"f=6",
"log":"ok",
"userid":"1020398130",
"id":"99",
"com":"003",
"sbcom":[
{"comname":"热水器开","comsring":"open"},
{"comname":"热水器关","comsring":"close"},
{"comname":"热水器开","comsring":"open"}
],
"feel":"003",
"sbfeel":[
{"feelnum":"123","feelname":"热水器","feelunit":"度","feelstyle":"1"},
{"feelnum":"123","feelname":"发动机位置","feelunit":"坐标","feelstyle":"2"},
{"feelnum":"123","feelname":"空调","feelunit":"湿度","feelstyle":"3"}
]
}
错误回复:
{
"dis":"f=6",
"log":"wrong"
}
Feelstyle:传感器类型,目前仅用 1 、2 ,1单值传感器,2GPS,此处并不表示值的个数,
比如3可以定义为双值传感器,具体定义随时根据网页说明更新


12、请求获取设备拥有的自定义菜单列表(微信用,以用户userid为标志)
URL:http://fuhome.net/api/sblist/
请求方式:GET/POST
openid=d32ffbe0ce1e7dccf15483d978365a40&userid=1020398130
&psw=4297f44b13955235245b2497399d7a93&f=12&time=1865423652

http://fuhome.net/api/sblist/
请求方式:GET/POST(微信用)
openid=d32ffbe0ce1e7dccf15483d978365a40& userid=1020398130&username=fromusername&f=12&time=1865423652

正确服务器回复:
{
"dis":"f=12",
"log":"ok",
"userid":"1020398130",
"com":"003",
"sbcom":[
{"comname":"热水器开","comsring":"open"},
{"comname":"热水器关","comsring":"close"},
{"comname":"热水器开","comsring":"open"}
]
}
错误回复:
{
"dis":"f=12",
"log":"wrong"
}

 

15、请求获取设备拥有的所有传感器(微信用,以用户userid为标志)
URL:http://fuhome.net/api/sblist/
请求方式:GET/POST
openid=d32ffbe0ce1e7dccf15483d978365a40&userid=1020398130
&psw=4297f44b13955235245b2497399d7a93&f=15&time=1865423652

http://fuhome.net/api/sblist/
请求方式:GET/POST(微信用)
openid=d32ffbe0ce1e7dccf15483d978365a40& userid=1020398130&username=fromusername&f=15&time=1865423652

正确服务器回复:
{
"dis":"f=15",
"log":"ok",
"userid":"1020398130",
"feel":"003",
"sbfeel":[
{"feelofsb":"9","feelnum":"123","feelname":"热水器","feelunit":"度","feelstyle":"1"},
{"feelofsb ":"1175","feelnum":"133","feelname":"发动机位置","feelunit":"坐标","feelstyle":"2"},
{"feelofsb ":"1003","feelnum":"143","feelname":"空调","feelunit":"湿度","feelstyle":"3"}
]
}
错误回复:
{
"dis":"f=15",
"log":"wrong"
}
http://fuhome.net/api/sblist/?openid= 83762687e6694006f6d1161864164d0f&username= obyu1jhlQTotLG7b0ozo9UGQS_bk&f=13&time=1865423652


13、请求获取设备拥有的已被授权的菜单列表(微信用,以为id为标志)
URL:http://fuhome.net/api/sblist/
请求方式:GET/POST
openid=d32ffbe0ce1e7dccf15483d978365a40&username=fromusername&f=13&time=1865423652

正确服务器回复:
{
"dis":"f=13",
"log":"ok",
"sbcom":[
{"comname":"热水器开","comsring":"open"},
{"comname":"热水器关","comsring":"close"},
{"comname":"热水器开","comsring":"open"}
],
"com":"003"
}
错误回复:
{
"dis":"f=13",
"log":"wrong"
}

 

7、增加设备自定义菜单
URL:http://fuhome.net/api/sblist/
请求方式:GET/POST
openid=d32ffbe0ce1e7dccf15483d978365a40&userid=1020398130
&psw=4297f44b13955235245b2497399d7a93&f=7&id=99&comname=打开&comstring=open&time=1865423652

正确服务器回复:
{
"dis":"f=7",
"log":"ok",
"userid":"1020398130",
"id":"99"
}
错误回复:
{
"dis":"f=7",
"log":"wrong"
}

Comname:命令菜单名称(汉字(UTF-8),字母,数字)
Comstring:命令字符内容(汉字(UTF-8),字母,数字,—)

 

8、绑定认证设备
URL:http://fuhome.net/api/sblist/
请求方式:GET/POST
openid=d32ffbe0ce1e7dccf15483d978365a40&userid=1020398130
&psw=4297f44b13955235245b2497399d7a93&serial=fuhome0102&
rzid=1287369152&rzmm=adf28d9b7a8d08b5&sbname=办公室的灯&f=8&time=1865423652

根据系列识别码,会自动添加菜单和传感器。

正确服务器回复:
{
"dis":"f=8",
"log":"ok",
"sbid":"1287369152",
"sbname":"办公室的灯"
}
错误回复:
{
"dis":"f=8",
"log":"wrong"
}
rzid:认证设备标签10位id
rzid:认证设备标签16位mm
Sbid:设备10位id
Sbname:设备名称

错误:设备id、密码错误或已经添加


14、获取命令菜单名称所对应的命令字符串
URL:http://fuhome.net/api/sblist/
请求方式:GET/POST
openid=d32ffbe0ce1e7dccf15483d978365a40&userid=1020398130
&psw=4297f44b13955235245b2497399d7a93&comname=opendoor&f=14&time=1865423652

正确服务器回复:
{
"dis":"f=14",
"log":"ok",
"id":"99",
"sbname":"房间的灯",
"comname":"opendoor",
"comstring":"open",

}
错误回复:
{
"dis":"f=14",
"log":"wrong"
}

 

 

10、请求最新传感器值
URL:http://fuhome.net/api/sblist/
请求方式:GET/POST
openid=d32ffbe0ce1e7dccf15483d978365a40&userid=1020398130
&psw=4297f44b13955235245b2497399d7a93&f=10&id=99&time=1865423652
id:返回的信息中的id(99是电风扇的id)

正确服务器回复:
{
"dis":"f=10",
"log":"ok",
"userid":"1020398130",
"id":"99",
"sbtime":"2016-05-22 15:00:07",

"statename":"状态",
"statevalue":"open"
"feel":"003",
"feelvalue":[
{"feelnum":"200","feelvalue1":"50","feelvalue2":"","feelvalue3":"","feeltime":"2016-05-22 15:00:07"},
{"feelnum":"201","feelvalue1":"112.0979","feelvalue2":"31.0978","feelvalue3":"","feeltime":"2016-05-22 15:00:07"},
{"feelnum":"202","feelvalue1":"50","feelvalue2":"","feelvalue3":"","feeltime":"2016-05-22 15:00:07"}
]
}
错误回复:
{
"dis":"f=10",
"log":"wrong"
}

 

 

11、请求指定时间段内的,指定数目的传感器值
URL:http://fuhome.net/api/sblist/
请求方式:GET/POST
openid=d32ffbe0ce1e7dccf15483d978365a40&userid=1020398130
&psw=4297f44b13955235245b2497399d7a93&f=11&id=99&unum=200
&time1=1474556095&time2=1474556595&count=10&time=1865423652
id:返回的信息中的id(99是电风扇的id)
Umun: 传感器3位数编号
Time1: 起始时间(Unix时间戳)可缺省
Time2: 终止时间(Unix时间戳)可缺省
Count: 条数,0为全部 其他则按实际获取,若大于实际条数,则按实际条数返回

http://fuhome.net/api/sblist/
请求方式:GET/POST(微信用)
openid=d32ffbe0ce1e7dccf15483d978365a40&userid=1020398130&username=fromusername&f=11&id=99&unum=200
&time1=1474556095&time2=1474556595&count=10&time=1865423652

正确服务器回复:
{
"dis":"f=11",
"log":"ok",
"id":"99",
"unum":"200",
"sbtime":"2016-05-22 15:00:07",
"statename":"状态",
"statevalue":"open"
"feelcount":"003",
"feelvalue":[
{"feelnum":"200","feelvalue1":"50","feelvalue2":"","feelvalue3":"","feeltime":"2016-05-22 15:00:07"},
{"feelnum":"200","feelvalue1":"112.0979","feelvalue2":"31.0978","feelvalue3":"","feeltime":"2016-05-22 15:00:07"},
{"feelnum":"200","feelvalue1":"50","feelvalue2":"","feelvalue3":"","feeltime":"2016-05-22 15:00:07"}
]
}
错误回复:
{
"dis":"f=11",
"log":"wrong"
}

 

附录:

其他错误集合:
W=1 :参数非法
W=2 :openid不可用
W=3 :用户psw错误
F=f :f类参数错误

 

 

 

 

未来之家,让科技融入生活 © 2014 fuhome.net, all rights reserved ICP 10208096