API列表
目录 |
用户授权类API列表
用户信息类接口 | 链接 | 描述 |
---|---|---|
passport/users/getLoggedInUser | #获取当前登录用户的信息 | 返回当前登录用户的用户名、用户uid、用户头像。 |
passport/users/getInfo | #返回用户资料 | 返回指定用户的用户资料。 |
passport/users/isAppUser | #判定当前用户是否已经为应用授权 | 判定当前用户是否已经为应用授权。 |
passport/users/hasAppPermission | #判断指定用户是否具有某个数据操作权限 | 判断指定用户是否具有某个数据操作权限。 |
passport/users/hasAppPermissions | #判断指定用户是否具有某一批数据操作权限 | 判断指定用户是否具有某一批数据操作权限。 |
好友关系类接口。 | 链接 | 描述 |
friends/getFriends | #返回用户好友资料 | 返回当前登录用户的双向好友列表。 |
friends/areFriends | #获得指定用户之间好友关系 | 获得指定用户之间是否是好友关系。第一个数组指定一半用户,第二个数组指定另外一半,两个数组必须同样的个数,一次最多可以查20个。 |
用户授权类接口 | 链接 | 描述 |
passport/auth/expireSession | #使access_token,session_key过期 | 使access_token,session_key过期。 |
passport/auth/revokeAuthorization | #撤销用户授予第三方应用的权限 | 撤销用户授予第三方应用的权限 |
超级个人中心通知提醒类接口 | 链接 | 描述 |
super/msg/setnum | #数据推送 | 数据推送接口。 |
super/msg/getnum | #数据查看 | 数据查看接口。 |
平台授权类API列表
- 通过用户授权,获取的access token可以继续调用这类API接口
- 通过[Client Credentials]方式获取access token,只能调用平台授权类API接口
团购类API列表
团购类接口 | 链接 | 描述 |
---|---|---|
saveOrder | #团购订单信息提交 | 团购订单信息提交(在付款成功后调用) |
updateExpire | #更新消费券有效期 | 更新消费券有效期(在更改消费券有效期后调用) |
useOrder | #标记消费券消为已用 | 标记消费券消为已用(在用户消费后调用) |
工具类API列表
工具类接口 | 链接 | 描述 |
---|---|---|
query | #查询IP地址所在地区 | 计算ip对应的省市数据。 |
高级API列表
- BQL和Batch Run接口,系统级参数access token需要根据传入的表类型或api类型进行选择,其余高级API,可以通过任意一种OAuth2.0授权方式获取的access token调用
高级API类接口 | 链接 | 描述 |
---|---|---|
BQL![]() | #BQL | Bql API采用SQL语法调用具有上下文关联的高级API |
Batch Run | #批量调用开放API | 批量调用openapi。 |
事件处理中心 | #事件处理中心 | 事件处理中心API是处理事件注册、订阅、触发相关的API |
获取当前登录用户的简单信息
https://openapi.baidu.com/rest/2.0/passport/users/getLoggedInUser
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
access_token | string | 是 | OAuth2.0验证授权后获得的token。 |
callback | string | 否 | 第三方通过JS调用开放API时可以通过指定callback参数来要求平台端返回JSONP代码,以解决跨域问题。 |
https://openapi.baidu.com/rest/2.0/passport/users/getLoggedInUser?access_token=xxx&
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
uid | uint | 是 | 67411167 | 当前登录用户的数字ID。 |
uname | string | 是 | robin928 | 当前登录用户的用户名。只用于显示,可能会发生变化,不保证全局唯一。 |
portrait | string | 是 | e2c1776c31393837313031319605 | 当前登录用户的头像。 |
如果存储用户信息的话,请大家以百度用户uid为主键。
头像的地址具体如下:
small image: http://tb.himg.baidu.com/sys/portraitn/item/{$portrait}
large image: http://tb.himg.baidu.com/sys/portrait/item/{$portrait}
{ "uid":2346677, "uname":"liupc24" "portrait":"e2c1776c31393837313031319605" }
返回用户详细资料
https://openapi.baidu.com/rest/2.0/passport/users/getInfo
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
access_token | string | 是 | OAuth2.0验证授权后获得的token。 |
callback | string | 否 | 第三方通过JS调用开放API时可以通过指定callback参数来要求平台端返回JSONP代码,以解决跨域问题。 |
username只能用于显示,可能会发生变化,不保证全局唯一。
https://openapi.baidu.com/rest/2.0/passport/users/getInfo?access_token=xxx
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
userid | uint | 是 | 67411167 | 当前登录用户的数字ID |
username | string | 否 | robin928 | 当前登录用户的用户名,值可能为空。 |
realname | string | 否 | 阳光 | 用户真实姓名,可能为空。 |
portrait | string | 否 | e2c1776c31393837313031319605 | 当前登录用户的头像 |
userdetail | string | 否 | 喜欢自由 | 自我简介,可能为空。 |
birthday | string | 否 | 1987-01-01 | 生日,以yyyy-mm-dd格式显示。 |
marriage | string | 否 | 已婚 | 婚姻状况 |
sex | string | 否 | 1 | 性别。"1"表示男,"0"表示女。 |
blood | string | 否 | O | 血型 |
figure | string | 否 | 小巧 | 体型 |
constellation | string | 否 | 射手 | 星座 |
education | string | 否 | 大学/专科 | 学历 |
trade | string | 否 | 计算机/电子产品 | 当前职业 |
job | string | 否 | 未知 | 职位 |
如果存储用户信息的话,请大家以百度用户uid为主键。
头像的地址具体如下:
small image: http://tb.himg.baidu.com/sys/portraitn/item/{$portrait}
large image: http://tb.himg.baidu.com/sys/portrait/item/{$portrait}
{ "userid":"2097322476", "username":"wl19871011", "realname":"阳光", "userdetail":"喜欢自由", "birthday":"1987-01-01", "marriage":"恋爱", "sex":"男", "blood":"O", "constellation":"射手", "figure":"小巧", "education":"大学/专科", "trade":"计算机/电子产品", "job":"未知", "birthday_year":"1987", "birthday_month":"01", "birthday_day":"01", }
判定当前用户是否已经为应用授权
https://openapi.baidu.com/rest/2.0/passport/users/isAppUser
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
access_token | string | 是 | OAuth2.0验证授权后获得的token。 |
callback | string | 否 | 第三方通过JS调用开放API时可以通过指定callback参数来要求平台端返回JSON代码,以解决跨域问题。 |
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
uid | unsigned int | 否 | 用户uid,为空则默认是当前用户 |
appid | int | 否 | 应用的appid,为空则默认是当前应用 |
https://openapi.baidu.com/rest/2.0/passport/users/isAppUser?access_token=xxx
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
result | int | 是 | 1 | 1表示已经授权该应用,0表示没有授权该应用。 |
{ "result":1 }
判断指定用户是否具有某个数据操作权限
https://openapi.baidu.com/rest/2.0/passport/users/hasAppPermission
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
access_token | string | 是 | OAuth2.0验证授权后获得的token。 |
callback | string | 否 | 第三方通过JS调用开放API时可以通过指定callback参数来要求平台端返回JSONP代码,以解决跨域问题。 |
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
ext_perm | string | 是 | 单个权限,例如接收email等,具体权限请查看权限列表。 |
uid | unsinged int | 否 | 用户uid,为空则默认是当前用户。 |
https://openapi.baidu.com/rest/2.0/passport/users/hasAppPermission?access_token=xxx
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
result | int | 是 | 1 | 1表示当前功能有操作权限,0表示当前功能没有操作权限。 |
{ "result":1 }
判断指定用户是否具有某一批数据操作权限
https://openapi.baidu.com/rest/2.0/passport/users/hasAppPermissions
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
access_token | string | 是 | OAuth2.0验证授权后获得的token。 |
callback | string | 否 | 第三方通过JS调用开放API时可以通过指定callback参数来要求平台端返回JSONP代码,以解决跨域问题。 |
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
ext_perms | string | 是 | 多个权限半角逗号隔开,例如basic,email等,具体权限请查看权限列表。 |
uid | unsinged int | 否 | 用户uid,为空则默认是当前用户。 |
https://openapi.baidu.com/rest/2.0/passport/users/hasAppPermissions?access_token=xxx
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
相应权限的名称 | int | 是 | 1 | 1表示当前功能有操作权限; 0表示当前功能没有操作权限。 |
{ "basic":"1", "email":"1" }
返回用户好友资料
https://openapi.baidu.com/rest/2.0/friends/getFriends
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
access_token | string | 是 | OAuth2.0验证授权后获得的token。 |
callback | string | 否 | 第三方通过JS调用开放API时可以通过指定callback参数来要求平台端返回JSONP代码,以解决跨域问题。 |
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
page_no | unsinged int | 否 | 用于支持分页的API, 0表示第1页,默认为0。 |
page_size | unsinged int | 否 | 用于支持分页的API,表示每页返回多少条数据,默认值500 |
sort_type | unsinged int | 否 | 按照添加时间排序,1:登陆时间排序,默认为0 |
https://openapi.baidu.com/rest/2.0/friends/getFriends?access_token=xxx
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
uname | string | 是 | sunshine | 好友的用户名 |
uid | string | 否 | 67411167 | 当前登录用户的数字ID。 |
portrait | string | 否 | - | 好友的用户头像加密串。 |
[{ "uname":"spacebj009", "uid":"2013411308", "portrait":"79787370616365626a3030393306" }, { "uname":"spacebj003", "uid":"2013412844", "portrait":"73787370616365626a3030333306" }]
获得指定用户之间好友关系
https://openapi.baidu.com/rest/2.0/friends/areFriends
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
access_token | string | 是 | OAuth2.0验证授权后获得的token。 |
callback | string | 否 | 第三方通过JS调用开放API时可以通过指定callback参数来要求平台端返回JSONP代码,以解决跨域问题。 |
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
uids1 | string | 是 | uids1、uids2每个uid都是以半角逗号隔开。二者个数必须相等。 |
uids2 | string | 是 | uids1、uids2每个uid都是以半角逗号隔开。二者个数必须相等。 |
https://openapi.baidu.com/rest/2.0/friends/areFriends?access_token=xxx
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
uid1 | string | 是 | 2013411564,2013411308 | 作为参数传入的uids1数组。 |
uid2 | string | 是 | 2013411308,2013411564 | 作为参数传入的uids2数组。 |
are_friends | uint | 是 | 0 | uid2是否是uid1的好友。 0表示非好友; 1表示好友。 |
are_friends_reverse | uint | 是 | 1 | uid1是否是uid2的好友。 0表示非好友; 1表示好友。 |
[{ "uid1":"2013411564", "uid2":"2013411308", "are_friends":"1", "are_friends_reverse":"1" }, { "uid1":" 2013411308", "uid2":"2013411564", "are_friends":"1", "are_friends_reverse":"1" }]
使access_token,session_key过期
https://openapi.baidu.com/rest/2.0/passport/auth/expireSession
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
access_token | string | 是 | OAuth2.0验证授权后获得的token。 |
callback | string | 否 | 第三方通过JS调用开放API时可以通过指定callback参数来要求平台端返回JSONP代码,以解决跨域问题。 |
https://openapi.baidu.com/rest/2.0/passport/auth/expireSession?access_token=xxx
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
result | int | 是 | 1 | 1成功,0失败 |
{ "result":1 }
撤销用户授予第三方应用的权限
https://openapi.baidu.com/rest/2.0/passport/auth/revokeAuthorization
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
access_token | string | 是 | OAuth2.0验证授权后获得的token。 |
callback | string | 否 | 第三方通过JS调用开放API时可以通过指定callback参数来要求平台端返回JSONP代码,以解决跨域问题。 |
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
uid | uint | 否 | 67411167 | 用户的ID,空则默认为当前用户 |
https://openapi.baidu.com/rest/2.0/passport/auth/revokeAuthorization?access_token=xxx
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
result | int | 是 | 1 | 1成功,0失败 |
{ "result":1 }
数据推送
https://openapi.baidu.com/rest/2.0/super/msg/setnum
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
access_token | string | 是 | OAuth2.0验证授权后获得的token。 |
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
msgdetail | string | 否 | 该参数必须n(消息类型总数)个数字,中间用英文逗号隔开,其顺序必须同消息类型模板一致。 例如:有两种消息类型为留言(20)和评论(30),则参数应为20,30。 若不填写,则默认只显示总数。 |
msgnum | int | 是 | 该消息的总数。例如:50(总数必须等于msgdetail中的数字和) |
https://openapi.baidu.com/rest/2.0/super/msg/setnum?access_token=xxx&msgdetail=xxx&msgnum=xxx
参数名称 | 是否必需 | 示例值 | 描述 |
---|---|---|---|
error_code | 是 | 错误码 | 100:“参数错误” 8000:“用户没有权限访问” 0:成功 |
error_msg | 否 | 错误消息 | 1:Invalid parameter 2:No Permissions 3:Success |
{"error_code":"100","error_msg":"Invalid parameter"}
数据查看
https://openapi.baidu.com/rest/2.0/super/msg/getnum
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
access_token | string | 是 | OAuth2.0验证授权后获得的token。 |
https://openapi.baidu.com/rest/2.0/super/msg/getnum?access_token=xxx&
参数名称 | 是否必需 | 描述 | 备注 |
---|---|---|---|
error_code | 是 | 错误码 |
100:“参数错误” 8000:“用户没有权限访问” 8001:“无数据” 0:成功 |
error_msg | 否 | 错误消息 |
1:Invalid parameter 2:No Permissions 3:No Data 4:Success |
{"error_code":"0","error_msg":""}
团购订单信息提交
订单回传时请使用post方式进行。同时注意一些非正规的post请求,如参数都拼接到url中,而post的数据为空。
https://openapi.baidu.com/rest/2.0/hao123/saveOrder
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
access_token | string | 是 | OAuth2.0验证授权后获得的token。 |
callback | string | 否 | 第三方通过JS调用开放API时可以通过指定callback参数来要求平台端返回JSONP代码,以解决跨域问题。 |
应用级输入参数编码为UTF-8,并使用POST方式进行HTTP请求,所有参数中不能包含html和js标签。
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
order_id | string | 是 | 订单号,在提交方系统中唯一(返回百度的订单号必须与返回给用户的订单号一致) |
order_time | integer | 是 | 用户下单时间,即订单号码生成的时间(非用户支付完成时间),自Jan 1 1970 00:00:00 GMT的秒数 |
order_city | string | 是 | 团购商品在百度团购API中对应的城市名称 |
title | string | 是 | 团购商品短标题 <255 bytes |
logo | string | 是 | 团购商品图片(海报)url<255bytes |
url | string | 是 | 团购商品url(需要和提交给百度导航的xml api中的商品地址完全一致)<255bytes |
price | integer | 是 | 商品单价 单位:分 如2100表示rmb21.00 |
goods_num | integer | 是 | 购买数量 |
sum_price | integer | 是 | 总价 单位:分 例如:300000 |
summary | string | 是 | 商品描述,例如: 价值186元的简单爱蛋糕(南瓜无糖)
<2048bytes |
expire | integer | 是 | 消费券过期时间,自Jan 1 1970 00:00:00 GMT的秒数; 0为不限制 |
addr | string | 否 | 商家地址,例如:朝阳区建国路178号汇通时代广场; <1024bytes |
uid | integer | 是 | 百度账号uid |
mobile | string | 否 | 用户手机号 |
tn | string | 是 | 百度推广渠道唯一ID,如为空,则表示非百度推广渠道的订单;否则为baidutuan_tg |
baiduid | string | 是 | 直接回传百度推广渠道带过去的32位 baiduid参数(不能做任何改动) |
bonus | integer | 是 | 百度分成金额(单位:分),bonus= price* goods_num *分成比例(若bonus=0,无分成) |
https://openapi.baidu.com/rest/2.0/hao123/saveOrder?access_token=xxx
参数名称 | 参数类型 | 是否必需 | 描述 | 备注 |
---|---|---|---|---|
error_code | int | 否 | 23013 | 错误代码,如无,则表示成功。 |
error_msg | string | 是 | success | 错误信息,成功则返回success。 |
id | int | 否 | 15123 | 成功分配的id号,建议记录在日志中,便于核对。 |
{"error_msg":"success","id":23231}
更新消费券有效期
https://openapi.baidu.com/rest/2.0/hao123/updateExpire
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
access_token | string | 是 | OAuth2.0验证授权后获得的token。 |
callback | string | 否 | 第三方通过JS调用开放API时可以通过指定callback参数来要求平台端返回JSONP代码,以解决跨域问题。 |
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
order_id | string | 是 | 订单号,在提交方系统中唯一(返回百度的订单号必须与返回给用户的订单号一致) |
order_ids | string | 是 | 订单号,在提交方系统中唯一,和创建提交的订单号一致;支持批量修改,多个使用英文逗号分隔。 |
expire | integer | 是 | 消费券过期时间,自Jan 1 1970 00:00:00 GMT的秒数; 0为不限制 |
https://openapi.baidu.com/rest/2.0/hao123/updateExpire?access_token=xxx
{"error_msg":"success","count":1}
标记消费券消为已用
https://openapi.baidu.com/rest/2.0/hao123/useOrder
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
access_token | string | 是 | OAuth2.0验证授权后获得的token。 |
callback | string | 否 | 第三方通过JS调用开放API时可以通过指定callback参数来要求平台端返回JSONP代码,以解决跨域问题。 |
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
order_id | string | 是 | 订单号,在提交方系统中唯一,和创建提交的订单号一致。 |
used_time | integer | 是 | 消费券使用时间,自Jan 1 1970 00:00:00 GMT的秒数。 |
{"error_msg":"success","count":1}
查询IP地址所在地区
https://openapi.baidu.com/rest/2.0/iplib/query
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
access_token | string | 是 | OAuth2.0验证授权后获得的token。 |
callback | string | 否 | 第三方通过JS调用开放API时可以通过指定callback参数来要求平台端返回JSONP代码,以解决跨域问题。 |
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
ip | string | 是 | 系统输入参数为编码为UTF-8格式编码。需要查询的ip地址,多个ip地址请用英文逗号隔开。 |
https://openapi.baidu.com/rest/2.0/iplib/query?amp;access_token=*****&ip=127.0.0.1,100.36.22.5
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
error_code | int | 否 | 23013 | 错误代码,如无,则表示成功 |
error_msg | string | 是 | success | 错误信息。 |
{ "220.181.50.242" :{"province":"\u5317\u4eac","city":"\u5317\u4eac"}, "61.174.63.198" :{"province":"\u6d59\u6c5f","city":"\u676d\u5dde"} }
{"error_code":"114","error_msg":"Invalid Ip"}
批量调用开放API
https://openapi.baidu.com/batch/run
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
access_token | string | 是 | OAuth2.0验证授权后获得的token。
注意:通过批量调用接口调用的OpenAPI,如果包含了用户授权类API,则access token必须是通过用户授权方式获取的access token,否则可以是通过[Client Credentials]方式获取access token |
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
method | string | 是 | mehtod的值是json格式的字符串。
具体构造如下: 必须是二维数组, 例如 array( array('domain' => 'openapi.baidu.com', 'path' => '/rest/2.0/passport/users/getLoggedInUser', 'params' => 'format=json&xxx', 'http_method' => 'post' ), ); 然后进行json_encode操作。
|
https://openapi.baidu.com/batch/run
POST表单如下:
access_token=xxx&method=[{"domain":"openapi.baidu.com", "path":"\/rest\/2.0\/passport\/users\/getLoggedInUser", "http_method":"get"}, {"domain":"openapi.baidu.com","path":"\/rest\/2.0\/passport\/users\/getInfo"}]
2.其余情况返回的都是json格式的字符串,解码后是多维数组。其索引值对应的客户端调用的相应开放API
[ { "uid":"123456789", "uname":"test", "portrait":"d77d776c31393837313031313306" }, { "userid":"123456789", "username":"test", "realname":"" } ]
BQL
https://openapi.baidu.com/bql/query
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
access_token | string | 是 | OAuth2.0验证授权后获得的token。
注意:通过BQL接口调用的OpenAPI,如果表名属于用户授权类,则access token必须是通过用户授权方式获取的access token,否则可以是通过[Client Credentials]方式获取access token |
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
q | string | 是 | q的值可以是单条sql语句,也可以是json格式的多条sql语句 |
Bql的语法完全跟sql语法保持一致
1.目前支持四种操作语句:select、insert、update、delete(使用时请看表说明,是否都支持这四种操作)
2.仅支持:and | in 子查询深度为3层(目前只针对select语句可以使用)
3.除insert外,其余语句必须要有where条件,如果对外提供的OpenAPI无业务级参数为了让第三方开发者更容易理解,可以使用user=me();作为where条件。
4.支持batch sql 形式如下:[{bql},{bql},{bql}](json格式的字符串),最多10个bql
5.提供公共函数me()获取当前用户uid
6.列名可以为具体的字段名(只返回该字段的结果集),也可以为*(返回符合where条件的所有结果集)。列名就是OpenAPI返回的参数(文档中对每个API都会列出其返回的参数)
7.where的条件既是OpenAPI的相关业务级参数,例如:where uid=123456(值为整型) and xxx='xxxxx'(值为字符串需要加成对的单/双引号)
例如: 1. 简单的bql语句 select * from passport.users.getInfo where uid=me() Update table set col_name=col_value where condtion=xxx Insert into table(col_name,...) values('col_value',..) Delete from table where condtion=xxx 2. 带子查询的bql语句 select * from passport.users.getInfo where uid in (select uid from friends.getFriends where uid=me()) 3. batch bql ["select * from passport.users.getInfo where uid=me();","select * from passport.users.getInfo where uid=me();"]
1.单条SQL调用
获取用户信息 https://openapi.baidu.com/bql/query?access_token=xxx&q=select%20*%20from%20passport.users.getInfo%20where%20uid=me() 获取好友信息 https://openapi.baidu.com/bql/query?access_token=xxx&q=select%20*%20from%20friends.getFriends%20where%20uid=me()
2.带子查询的SQL调用
获取用户好友的个人信息 https://openapi.baidu.com/bql/query ?access_token=xxx&q=select%20*%20from%20passport.users.getInfo%20where%20uid%20in%20(select%20uid%20from%20friends.getFriends%20where%20uid=me())
3.批量BQL调用
获取用户信息 https://openapi.baidu.com/bql/query?access_token=xxx&q=["select%20*%20from%20passport.users.getInfo%20where%20uid=me()","select%20*%20from%20passport.users.getInfo%20where%20uid=me()"]
2.其余情况返回的都是json格式的字符串,解码后是多维数组。其索引值对应的客户端调用的相应开放API。
事件处理中心
注册私有事件
https://openapi.baidu.com/rest/2.0/epc/v1/callback/add
{ "event_id":55388e3f1a5dfcc089a1d6517cd68bd6, "event_name":test, "callback":http://example.baidu.com, }
查询私有事件
https://openapi.baidu.com/rest/2.0/epc/v1/callback/get
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
event_id | String | 否 | 55388e3f1a5dfcc089a1d6517cd68bd6 | 事件ID |
{ "event_id":55388e3f1a5dfcc089a1d6517cd68bd6, "event_name":test, "callback":http://example.baidu.com, }
更新私有事件
https://openapi.baidu.com/rest/2.0/epc/v1/callback/update
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
event_id | String | 是 | 55388e3f1a5dfcc089a1d6517cd68bd6 | 事件id |
event_name | String | 是 | test | 事件名称 |
callback | String | 是 | http://example.baidu.com | 事件回调地址 |
{ "event_id":55388e3f1a5dfcc089a1d6517cd68bd6, "event_name":test, "callback":http://example.baidu.com, }
删除私有事件
https://openapi.baidu.com/rest/2.0/epc/v1/callback/delete
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
event_id | String | 是 | 55388e3f1a5dfcc089a1d6517cd68bd6 | 事件ID |
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
result | Number | 否 | 1 | 状态 |
{ "result":1, }
触发私有事件
https://openapi.baidu.com/rest/2.0/epc/v1/callback/trigger
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
msg_id | String | 是 | 55388e3f1a5dfcc089a1d6517cd68bd6 | 事件信息id |
{ "msg_id":55388e3f1a5dfcc089a1d6517cd68bd6, }
注册普通事件
https://openapi.baidu.com/rest/2.0/epc/v1/event/add
{ "event_id":55388e3f1a5dfcc089a1d6517cd68bd6, "event_name":test, "producer":10000,10001, "subscriber":10000,10001, }
查看普通事件
https://openapi.baidu.com/rest/2.0/epc/v1/event/get
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
event_id | String | 否 | 55388e3f1a5dfcc089a1d6517cd68bd6 | 事件ID |
{ "event_id":55388e3f1a5dfcc089a1d6517cd68bd6, "event_name":test, "producer":10000,10001, "subscriber":10000,10001, }
更新普通事件
https://openapi.baidu.com/rest/2.0/epc/v1/event/update
{ "event_id":55388e3f1a5dfcc089a1d6517cd68bd6, "event_name":test, "producer":10000,10001, "subscriber":10000,10001, }
删除普通事件
https://openapi.baidu.com/rest/2.0/epc/v1/event/delete
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
event_id | String | 是 | 55388e3f1a5dfcc089a1d6517cd68bd6 | 事件ID |
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
result | Number | 否 | 1 | 状态 |
{ "result":1, }
触发普通事件
https://openapi.baidu.com/rest/2.0/epc/v1/event/trigger
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
result | Number | 否 | 1 | 状态 |
{ "msg_id":55388e3f1a5dfcc089a1d6517cd68bd4, }
订阅普通事件
https://openapi.baidu.com/rest/2.0/epc/v1/subscription/add
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
event_id | String | 是 | 55388e3f1a5dfcc089a1d6517cd68bd6 | 事件id |
url | String | 是 | http://example.baidu.com | 事件回调地址 |
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
sub_id | String | 是 | f3d194a78eb7f3a4bf20be8ee878d0c3 | 订阅关系id |
event_id | String | 是 | 55388e3f1a5dfcc089a1d6517cd68bd6 | 事件id |
callback | String | 是 | http://example.baidu.com | 事件回调地址 |
{ "sub_id":f3d194a78eb7f3a4bf20be8ee878d0c3, "event_id":55388e3f1a5dfcc089a1d6517cd68bd6, "callback":http://example.baidu.com, }
查询普通事件订阅信息
https://openapi.baidu.com/rest/2.0/epc/v1/subscription/get
参数名称 | 参数类型 | 是否必需 | 描述 |
---|---|---|---|
access_token | string | 是 | OAuth2.0验证授权后获得的token。 |
callback | String | 否 | JS回调处理函数名,第三方应用在浏览器端通过JS调用Open API时都需要用到,用以解决浏览器跨域问题。该参数不为空时,百度Open API服务器将返回JSONP格式的响应结果,否则返回的是JSON格式的响应结果。 |
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
sub_id | String | 否 | f3d194a78eb7f3a4bf20be8ee878d0c3 | 订阅关系ID |
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
sub_id | String | 是 | f3d194a78eb7f3a4bf20be8ee878d0c3 | 订阅关系ID |
event_id | String | 是 | 55388e3f1a5dfcc089a1d6517cd68bd6 | 事件id |
callback | String | 是 | http://example.baidu.com | 事件回调地址 |
{ "sub_id":f3d194a78eb7f3a4bf20be8ee878d0c3, "event_id":55388e3f1a5dfcc089a1d6517cd68bd6, "callback":http://example.baidu.com, }
修改普通事件订阅关系
https://openapi.baidu.com/rest/2.0/epc/v1/subscription/update
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
sub_id | String | 是 | f3d194a78eb7f3a4bf20be8ee878d0c3 | 订阅关系ID |
url | String | 否 | http://example.baidu.com | 事件回调地址 |
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
sub_id | String | 是 | f3d194a78eb7f3a4bf20be8ee878d0c3 | 订阅关系ID |
event_id | String | 是 | 55388e3f1a5dfcc089a1d6517cd68bd6 | 事件id |
callback | String | 是 | http://example.baidu.com | 事件回调地址 |
{ "sub_id":f3d194a78eb7f3a4bf20be8ee878d0c3, "event_id":55388e3f1a5dfcc089a1d6517cd68bd6, "callback":http://example.baidu.com, }
取消订阅普通事件
https://openapi.baidu.com/rest/2.0/epc/v1/subscription/delete
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
sub_id | String | 是 | f3d194a78eb7f3a4bf20be8ee878d0c3 | 订阅关系id |
参数名称 | 参数类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
result | Number | 否 | 1 | 状态 |
{ "result":1, }
获取可订阅普通事件列表
https://openapi.baidu.com/rest/2.0/epc/v1/subscription/eventlist
{ "event_id":55388e3f1a5dfcc089a1d6517cd68bd6, "event_name":test, }