微信网页版本开发接口
Web Weixin API
登录
API: 获取UUID
Url: https://login.weixin.qq.com/jslogin
Method: POST
Data: URL Encode
Params:
appid: 应用ID
fun: new 应用类型
lang: zh_CN 语言
_: 时间戳
返回数据(String):
window.QRLogin.code = 200; window.QRLogin.uuid = "xxx"
API: 生成二维码
Url : https://login.weixin.qq.com/l/ uuid
API: 二维码扫描登录
Url: https://login.weixin.qq.com/cgi-bin/mmwebwx-bin/login
Method: GET
Params:
tip: 0 已扫描 1 未扫描
uuid: xxx
_: 时间戳
返回数据(String):
window.code=xxx;
xxx:
408 登陆超时
201 扫描成功
200 确认登录
当返回200时,还会有
window.redirect_uri="https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage?ticket=xxx&uuid=xxx&lang=xxx&scan=xxx";
API: webwxnewloginpage
Url: https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage
Method: GET
Params:
ticket: xxx
uuid: xxx
lang: zh_CN 语言
scan: xxx
fun: new
返回数据(String):
<error>
<ret>0</ret>
<message>OK</message>
<skey>xxx</skey>
<wxsid>xxx</wxsid>
<wxuin>xxx</wxuin>
<pass_ticket>xxx</pass_ticket>
<isgrayscale>1</isgrayscale>
</error>
消息接口
API: webwxsendmsg
Url: https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxsendmsg?pass_ticket=xxx
Method: POST
Data: JSON
Header: ContentType: application/json; charset=UTF-8
Params:
{
BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx },
Msg: {
Type: 1 文字消息,
Content: 要发送的消息,
FromUserName: 自己ID,
ToUserName: 好友ID,
LocalID: 与clientMsgId相同,
ClientMsgId: 时间戳左移4位随后补上4位随机数
}
}
返回数据(JSON):
{
"BaseResponse": {
"Ret": 0,
"ErrMsg": ""
},
...
}
详细可以参考下面文档
http://blog.csdn.net/wonxxx/article/details/51787041
网友点评