可以获取投票列表展示在公司的OA主页,让乐享更好地服务公司
GET https://lxapi.lexiangla.com/cgi-bin/v1/surveys
支持分页参数和排序:(通用说明?)
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
sort | 否 | -created_at | 排序参数,支持按投票的created_at , ended_at 排序 |
filter | 否 | public | public :公开可见的投票;all :全部投票; |
page | 否 | 1 | 当前页数 |
per_page | 否 | 20 | 每页返回的数量 |
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get('surveys', [
'page'=> 1,
'per_page' => 3,
//'sort' => 'created_at',
]);
document
{
"data":[
{
"type":"survey",
"id":"47ba342c9ba411e8ba725254009b5a66",
"attributes":{
"title":"中秋福利--月饼邮寄地址统计",
"summary":"",
"created_at":"2018-08-09 15:17:31",
"ended_at":"2018-08-25 15:09:00",
"read_count":21,
"type":"normal",
"comment_count":0,
"participant_count":0,
"privilege_type":0
},
"links":{
"platform":"https://lexiangla.com/teams/k100251/surveys/47ba342c9ba411e8ba725254009b5a66"
},
"relationships":{
"owner":{
"data":{
"type":"staff",
"id":"ThreeZhang"
}
},
"team":{
"data":{
"type":"team",
"id":"e61097f08e4411e88d675254009b5a66"
}
}
}
},
{
"type":"survey",
"id":"ad74752693dd11e88b8b5254009b5a66",
"attributes":{
"title":"课程学习意见反馈采集",
"summary":"",
"created_at":"2018-07-30 17:48:14",
"ended_at":null,
"read_count":8,
"type":"normal",
"comment_count":2,
"participant_count":1,
"privilege_type":0
},
"links":{
"platform":"https://lexiangla.com/teams/k100145/surveys/ad74752693dd11e88b8b5254009b5a66"
},
"relationships":{
"owner":{
"data":{
"type":"staff",
"id":"FourLee"
}
},
"team":{
"data":{
"type":"team",
"id":"c2d93650db2211e7b87d5254002b6735"
}
}
}
},
{
"type":"survey",
"id":"5447ec3a93dd11e8941c5254009b5a66",
"attributes":{
"title":"xxx公示意见采集",
"summary":"",
"created_at":"2018-07-30 17:45:44",
"ended_at":null,
"read_count":8,
"type":"normal",
"comment_count":1,
"participant_count":1,
"privilege_type":0
},
"links":{
"platform":"https://lexiangla.com/teams/K10/surveys/5447ec3a93dd11e8941c5254009b5a66"
},
"relationships":{
"owner":{
"data":{
"type":"staff",
"id":"TwoWang"
}
},
"team":{
"data":{
"type":"team",
"id":"fc59bc42781711e797c25254002b6735"
}
}
}
}
],
"links":{
"first":"https://lxapi.lexiangla.com/cgi-bin/v1/surveys?filter=hot&date_range=30&per_page=3&page=1",
"last":"https://lxapi.lexiangla.com/cgi-bin/v1/surveys?filter=hot&date_range=30&per_page=3&page=21",
"prev":null,
"next":"https://lxapi.lexiangla.com/cgi-bin/v1/surveys?filter=hot&date_range=30&per_page=3&page=2"
},
"meta":{
"current_page":1,
"from":1,
"last_page":21,
"path":"https://lxapi.lexiangla.com/cgi-bin/v1/surveys",
"per_page":"3",
"to":3,
"total":63
},
"included":[
{
"type":"staff",
"id":"ThreeZhang",
"attributes":{
"name":"张三",
"english_name":"ThreeZhang",
"organization":"运营组"
}
},
{
"type":"staff",
"id":"FourLee",
"attributes":{
"name":"李四",
"english_name":"FourLee",
"organization":"产品组"
}
},
{
"type":"staff",
"id":"TwoWang",
"attributes":{
"name":"王二",
"english_name":"TwoWang",
"organization":"开发组"
}
},
{
"type":"team",
"id":"e61097f08e4411e88d675254009b5a66",
"attributes":{
"name":"team1"
}
},
{
"type":"team",
"id":"c2d93650db2211e7b87d5254002b6735",
"attributes":{
"name":"team2"
}
},
{
"type":"team",
"id":"fc59bc42781711e797c25254002b6735",
"attributes":{
"name":"team3"
}
}
]
}
参数 | 说明 |
---|---|
survey.type | 资源对象类型,为survey,表示资源为投票 |
survey.id | 投票实体ID |
survey.links.platform | 投票查看页面,可以直接跳转到乐享投票详情页面 |
survey.title | 投票的标题 |
survey.summary | 投票的摘要内容 |
survey.created_at | 投票的创建时间 |
survey.ended_at | 投票的截止时间 |
survey.read_count | 投票的访问量 |
survey.type | 投票的类型 |
survey.comment_count | 投票的评论数量 |
survey.participant_count | 投票的参数人数 |
survey.privilege_type | 投票的公开情况,0表示公开,1表示非公开,2表示仅创建者可见 |
relationships.owner | 投票的创建人 |
relationships.team | 投票所属的K吧 |
获取单个投票的参与人员接口
GET https://lxapi.lexiangla.com/cgi-bin/v1/surveys/{id}/participants
支持分页参数和排序:(通用说明?)
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
id | 是 | 无 | 投票ID |
page | 否 | 1 | 当前页数 |
per_page | 否 | 500 | 每页返回的数量,最大值2000 |
对于指定id参数,仅允许单个线程发起请求,请按分页信息逐页拉取。
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get('surveys/id/participants');
document
{
"data": [
{
"type": "staff",
"id": "ThreeZhang",
"attributes": {
"name": "张三",
"english_name": "ThreeZhang",
"organization": "开发组",
"voted_at": "2020-05-31 11:54:00"
}
},
{
"type": "staff",
"id": "FourLee",
"attributes": {
"name": "李四",
"english_name": "FourLee",
"organization": "开发组",
"voted_at": "2020-05-31 11:54:13"
}
},
{
"type": "staff",
"id": "FiveWang",
"attributes": {
"name": "王五",
"english_name": "FiveWang",
"organization": "开发组",
"voted_at": "2020-05-31 11:54:25"
}
}
],
"links": {
"first": "https://lxapi.lexiangla.com/cgi-bin/v1/surveys/37a0e036648611e886ca492879fbd29f/participants?page=1",
"last": null,
"prev": null,
"next": null
},
"meta": {
"current_page": 1,
"from": 1,
"path": "https://lxapi.lexiangla.com/cgi-bin/v1/surveys/37a0e036648611e886ca492879fbd29f/participants",
"per_page": 500,
"to": 3
}
}
分页信息meta
中不会返回last_page
(最后一页的页码)和total
(总数),links.last
也会固定为 null
需要拉取所有分页数据,可根据当前页返回data
是否空集,或者判断links.next
是否空,来决定是否继续拉取下一页数据
{
"errors": [
{
"detail": "请求并发数超过限制"
}
]
}
参数 | 说明 |
---|---|
voted_at | 投票时间(注意:不记名投票不提供投票时间) |