POST https://lxapi.lexiangla.com/cgi-bin/v1/questions
document
{
"data":{
"type":"question",
"attributes":{
"title":"API创建的乐问标题",
"content":"<p>PHP是最好的语言</p>",
"is_anonymous":0,
"tags":[
"PHP",
"乐问",
"API"
]
}
}
}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
type | 是 | 无 | 资源对象类型,必须为 question,表示问题 |
question.title | 是 | 无 | 乐问标题,最大长度为100字节 |
question.content | 是 | 无 | 乐问内容,可以为富文本内容 |
question.is_anonymous | 是 | 无 | 是否匿名,1表示匿名,0表示不匿名 |
question.tags | 是 | 无 | 问题标签,必须为数组 |
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$attributes = [
'title' => 'API创建的乐问标题',
'content' => '<p>PHP是最好的语言</p>',
'is_anonymous' => 0,
'tags' => ['PHP', '乐问', 'API'],
];
$response = $Lxapi->postQuestion(StaffID, $attributes);
document
{
"data":{
"type":"question",
"id":"65b0f088a5c211e8ac0b10e7c61c70fc",
"attributes":{
"title":"API创建的乐问标题",
"is_anonymous": 0,
"content":"<p>PHP是最好的语言</p>",
"read_count": 0,
"answer_count": 0,
"concern_count": 0,
"created_at":"2018-08-21 04:18:16",
"updated_at":"2018-08-21 04:18:16"
},
"relationships":{
"owner":{
"data":{
"type":"staff",
"id":"ThreeZhang"
}
},
"tags":{
"data":[
{
"type":"tag",
"id":"db768572a5c111e89e5c10e7c61c70fc"
},
{
"type":"tag",
"id":"db76cc44a5c111e89ddb10e7c61c70fc"
},
{
"type":"tag",
"id":"db770ac4a5c111e8904e10e7c61c70fc"
}
]
}
}
},
"included":[
{
"type":"staff",
"id":"ThreeZhang",
"attributes":{
"name":"张三",
"english_name":"ThreeZhang",
"organization":"运营组"
}
},
{
"type":"tag",
"id":"db768572a5c111e89e5c10e7c61c70fc",
"attributes":{
"name":"PHP"
}
},
{
"type":"tag",
"id":"db76cc44a5c111e89ddb10e7c61c70fc",
"attributes":{
"name":"乐问"
}
},
{
"type":"tag",
"id":"db770ac4a5c111e8904e10e7c61c70fc",
"attributes":{
"name":"API"
}
}
]
}
GET https://lxapi.lexiangla.com/cgi-bin/v1/questions
支持分页参数和排序:(通用说明?)
支持时间范围过滤
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
list_type | 否 | 无 | 若值为 hot,则拉取热问列表。否则列表按创建时间倒叙 |
date_range | 否 | 7 | 仅当 list_type=hot 时有效,表示拉取n天内的热门问题,默认值为7天 |
tag_name | 否 | 无 | 通过标签名筛选乐问问题 |
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get('questions?list_type=hot&date_range=3');
// $response = $Lxapi->get('questions?tag_name=福利');
document
{
"data": [
{
"relationships": {
"owner": {
"data": {
"id": "ThreeZhang",
"type": "staff"
}
},
"tags": {
"data": [
{
"id": "a01d2056535c11e8a3095254002b6735",
"type": "tag"
}
]
}
},
"attributes": {
"summary": "测试一下 ...",
"concern_count": 0,
"updated_at": "2021-08-02 15:59:49",
"is_anonymous": 0,
"created_at": "2021-08-02 10:47:18",
"title": "标题?",
"answer_count": 1,
"read_count": 9
},
"id": "f3b7dae4f33b11eb80d54a90361540c2",
"type": "question"
}
],
"meta": {
"path": "https:\/\/lxapi.lexiangla.com\/cgi-bin\/v1\/questions",
"per_page": 1,
"total": 2259,
"last_page": 2259,
"from": 1,
"to": 1,
"current_page": 1
},
"links": {
"next": "https:\/\/lxapi.lexiangla.com\/cgi-bin\/v1\/questions?per_page=1&page=2",
"last": "https:\/\/lxapi.lexiangla.com\/cgi-bin\/v1\/questions?per_page=1&page=2259",
"prev": null,
"first": "https:\/\/lxapi.lexiangla.com\/cgi-bin\/v1\/questions?per_page=1&page=1"
},
"included": [
{
"attributes": {
"organization": "1",
"name": "ThreeZhang",
"english_name": null
},
"id": "ThreeZhang",
"type": "staff"
},
{
"attributes": {
"recommended_at": null,
"name": "测试标签"
},
"id": "a01d2056535c11e8a3095254002b6735",
"type": "tag"
}
]
}
GET https://lxapi.lexiangla.com/cgi-bin/v1/questions/{question_id}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
question_id | 是 | 无 | question 中资源对象类型为question的资源对象id,即乐问id |
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get('questions/c217bd40916b11e88bf75254009b5a66');
document
{
"data":{
"type":"question",
"id":"65b0f088a5c211e8ac0b10e7c61c70fc",
"attributes":{
"title":"API创建的乐问标题",
"is_anonymous":0,
"content":"<p>PHP是最好的语言</p>",
"read_count":0,
"answer_count":0,
"concern_count":0,
"created_at":"2018-08-21 04:18:16",
"updated_at":"2018-08-21 04:18:16"
},
"relationships":{
"owner":{
"data":{
"type":"staff",
"id":"ThreeZhang"
}
},
"tags":{
"data":[
{
"type":"tag",
"id":"db768572a5c111e89e5c10e7c61c70fc"
},
{
"type":"tag",
"id":"db76cc44a5c111e89ddb10e7c61c70fc"
},
{
"type":"tag",
"id":"db770ac4a5c111e8904e10e7c61c70fc"
}
]
}
}
},
"included":[
{
"type":"staff",
"id":"ThreeZhang",
"attributes":{
"name":"张三",
"english_name":"ThreeZhang",
"organization":"运营组"
}
},
{
"type":"tag",
"id":"db768572a5c111e89e5c10e7c61c70fc",
"attributes":{
"name":"PHP"
}
},
{
"type":"tag",
"id":"db76cc44a5c111e89ddb10e7c61c70fc",
"attributes":{
"name":"乐问"
}
},
{
"type":"tag",
"id":"db770ac4a5c111e8904e10e7c61c70fc",
"attributes":{
"name":"API"
}
}
]
}
{
"errors":{
"detail":"不存在ID为`c217bd40916b11e88bf75254009b5a26`的question资源"
}
}
PATCH https://lxapi.lexiangla.com/cgi-bin/v1/questions/{question_id}
document
{
"data":{
"type":"question",
"attributes":{
"title":"API创建的乐问标题,修改乐问的标题",
"content":"<p>PHP是最好的语言</p>",
"tags":[
"PHP",
"乐问",
"API"
]
}
}
}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
question_id | 是 | 无 | 资源对象类型为question的资源对象id,即乐问id |
type | 是 | 无 | 资源对象类型,必须为 question,表示问题 |
question.title | 是 | 无 | 乐问标题,最大长度为100字节 |
question.content | 是 | 无 | 乐问内容,可以为富文本内容 |
question.tags | 是 | 无 | 问题标签,必须为数组 |
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$attributes = [
'title' => 'API创建的乐问标题,修改乐问的标题',
'content' => '<p>PHP是最好的语言</p>',
'tags' => ['PHP', '乐问', 'API'],
];
$response = $Lxapi->patchQuestion(StaffID,'65b0f088a5c211e8ac0b10e7c61c70fc', $attributes);
document
{
"data":{
"type":"question",
"id":"65b0f088a5c211e8ac0b10e7c61c70fc",
"attributes":{
"title":"API创建的乐问标题,修改乐问的标题",
"is_anonymous":0,
"content":"<p>PHP是最好的语言</p>",
"read_count":0,
"answer_count":0,
"concern_count":0,
"created_at":"2018-08-21 04:18:16",
"updated_at":"2018-08-22 12:23:50"
},
"relationships":{
"owner":{
"data":{
"type":"staff",
"id":"ThreeZhang"
}
},
"tags":{
"data":[
{
"type":"tag",
"id":"db768572a5c111e89e5c10e7c61c70fc"
},
{
"type":"tag",
"id":"db76cc44a5c111e89ddb10e7c61c70fc"
},
{
"type":"tag",
"id":"db770ac4a5c111e8904e10e7c61c70fc"
}
]
}
}
},
"included":[
{
"type":"staff",
"id":"ThreeZhang",
"attributes":{
"name":"张三",
"english_name":"ThreeZhang",
"organization": "运营组"
}
},
{
"type":"tag",
"id":"db768572a5c111e89e5c10e7c61c70fc",
"attributes":{
"name":"PHP"
}
},
{
"type":"tag",
"id":"db76cc44a5c111e89ddb10e7c61c70fc",
"attributes":{
"name":"乐问"
}
},
{
"type":"tag",
"id":"db770ac4a5c111e8904e10e7c61c70fc",
"attributes":{
"name":"API"
}
}
]
}
{
"errors":{
"detail":"不存在ID为`65b0f088a5c211e8ac0b10e7c61c70f2`的question资源"
}
}
DELETE https://lxapi.lexiangla.com/cgi-bin/v1/questions/{question_id}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
question_id | 是 | 无 | 资源对象类型为question的资源对象id,即乐问id |
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->deleteQuestion(StaffID, '65b0f088a5c211e8ac0b10e7c61c70fc');
document
[]
{
"errors":{
"detail":"不存在ID为`65b0f088a5c211e8ac0b10e7c61c70ff`的question资源"
}
}
POST https://lxapi.lexiangla.com/cgi-bin/v1/questions/{question_id}/answers
document
{
"data":{
"type":"answer",
"attributes":{
"content":"<p>通过LXAPI创建的回答</p>",
"is_anonymous":0
}
}
}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
question_id | 是 | 无 | question 中资源对象类型为question的资源对象ID,即乐问id |
type | 是 | 无 | 资源对象类型,必须为answer,表示乐问回答 |
answer.content | 是 | 无 | 回答的内容,支持富文本内容 |
answer.is_anonymous | 是 | 无 | 是否匿名回答,1表示匿名,0表示不匿名 |
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$attributes = [
'content' => '<p>通过LXAPI创建的回答</p>',
'is_anonymous' => 0,
];
$response = $Lxapi->postQuestionAnswer(StaffID, '65b0f088a5c211e8ac0b10e7c61c70fc', $attributes);
{
"data":{
"type":"answer",
"id":"56fdb4faa5c611e89baa10e7c61c70fc",
"attributes":{
"content":"<p>通过LXAPI创建的回答</p>",
"created_at":"2018-08-20 04:46:30",
"updated_at":"2018-08-20 04:46:30"
},
"relationships":{
"owner":{
"data":{
"type":"staff",
"id":"ThreeZhang"
}
}
}
},
"included":[
{
"type":"staff",
"id":"ThreeZhang",
"attributes":{
"name":"张三",
"english_name":"ThreeZhang",
"organization":"运营组"
}
}
]
}
{
"errors":{
"detail":"不存在ID为`65b0f088a5c211e8ac0b10e7c61c70f2`的question资源"
}
}
PATCH https://lxapi.lexiangla.com/cgi-bin/v1/questions/{question_id}/answers/{answer_id}
document
{
"data":{
"type":"answer",
"attributes":{
"content":"<p>通过LXAPI创建的回答</p><p>修改回答的内容</p>"
}
}
}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
question_id | 是 | 无 | 资源对象类型为question的资源对象id,即乐问id |
answer_id | 是 | 无 | 资源对象类型为answer的资源对象id,即乐问回答id |
type | 是 | 无 | 资源对象类型,必须为answer,表示乐问回答 |
answer.content | 是 | 无 | 回答的内容,支持富文本内容 |
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$attributes = [
'content' => '<p>通过LXAPI创建的回答</p><p>修改回答的内容</p>',
];
$response = $Lxapi->patchQuestionAnswer(StaffID, '65b0f088a5c211e8ac0b10e7c61c70fc', '56fdb4faa5c611e89baa10e7c61c70ff', $attributes);
document
{
"data":{
"type":"answer",
"id":"56fdb4faa5c611e89baa10e7c61c70fc",
"attributes":{
"is_anonymous":0,
"content":"<p>通过LXAPI创建的回答</p><p>修改回答的内容</p>",
"pinned_at":null,
"created_at":"2018-08-20 04:46:30",
"updated_at":"2018-08-22 14:14:06"
},
"relationships":{
"owner":{
"data":{
"type":"staff",
"id":"ThreeZhang"
}
}
}
},
"included":[
{
"type":"staff",
"id":"ThreeZhang",
"attributes":{
"name":"张三",
"english_name":"ThreeZhang",
"organization":"运营组"
}
}
]
}
{
"errors":{
"detail":"不存在ID为`56fdb4faa5c611e89baa10e7c61c70ff`的answer资源"
}
}
DELETE https://lxapi.lexiangla.com/cgi-bin/v1/questions/{question_id}/answers/{answer_id}
document
[]
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
question_id | 是 | 无 | 资源对象类型为question的资源对象id,即乐问id |
answer_id | 是 | 无 | 资源对象类型为answer的资源对象id,即乐问回答id |
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->deleteQuestionAnswer(StaffID, '65b0f088a5c211e8ac0b10e7c61c70fc', '56fdb4faa5c611e89baa10e7c61c70fc');
document
[]
{
"errors":{
"detail":"不存在ID为`56fdb4faa5c611e89baa10e7c61c70ff`的answer资源"
}
}
GET https://lxapi.lexiangla.com/cgi-bin/v1/questions/{question_id}/answers/{answer_id}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
question_id | 是 | 无 | 问题的id |
answer_id | 是 | 无 | 回答的id |
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get("questions/" . $question_id . "/answers/" . $answer_id);
document
{
"data": {
"type": "answer",
"id": "fe693c8c3c4a11eca4af925ec492f07e",
"attributes": {
"is_anonymous": 0,
"content": "测试回答乐问",
"summary": "测试回答乐问",
"comment_count": 0,
"like_count": 0,
"pinned_at": null,
"created_at": "2021-11-03 10:08:53",
"updated_at": "2021-11-03 10:08:53"
},
"relationships": {
"owner": {
"data": {
"type": "staff",
"id": "threezhang"
}
},
"question": {
"data": {
"type": "question",
"id": "5f689f7c3af311ecaafc36049aa9bfaf"
}
}
}
},
"included": [{
"type": "staff",
"id": "threezhang",
"attributes": {
"name": "张三",
"english_name": null,
"organization": "测试组 "
}
},
{
"type": "question",
"id": "5f689f7c3af311ecaafc36049aa9bfaf",
"attributes": {
"title": "乐问标题",
"is_anonymous": 0,
"summary": "邀请成员回答乐问",
"content": "邀请成员回答乐问",
"read_count": 29,
"answer_count": 4,
"concern_count": 0,
"created_at": "2021-11-01 17:09:09",
"updated_at": "2021-11-03 10:08:53"
}
}
],
"links": {
"self": "https://lxapi.lexiangla.com/cgi-bin/v1/questions/5f689f7c3af311ecaafc36049aa9bfaf/answers/fe693c8c3c4a11eca4af925ec492f07e"
}
}
参数 | 说明 |
---|---|
answer.summary | 回答的摘要 |
answer.content | 回答的内容 |
answer.comment_count | 回答的评论数 |
answer.like_count | 回答的点赞数量 |
answer.created_at | 回答的创建日期 |
answer.updated_at | 回答的更新日期 |
answer.is_anonymous | 回答是否匿名,1表示匿名,0表明不匿名 |
answer.pinned_at | 是否被置顶,null表示没被置顶,置顶则显示被置顶的日期 |
answer.id | 回答的id |
relationships.owner.id | 回答创建者id |
included.staff | 回答创建者,属性参考获取单个成员数据 |
included.staff.organization | 回答创建者的所属部门 |
GET https://lxapi.lexiangla.com/cgi-bin/v1/questions/{question_id}/answers
支持分页参数和排序:(通用说明?)
支持时间范围过滤
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
question_id | 是 | 无 | 问题的id |
per_page | 否 | 无 | 每页返回的数量 |
page | 否 | 无 | 当前页数 |
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get('questions/' . $question_id . '/answers', [
"per_page" => 10,
"page" => 1
]);
document
{
"data":[
{
"type":"answer",
"id":"56fdb4faa5c611e89baa10e7c61c70fc",
"attributes":{
"is_anonymous":0,
"content":"<p>通过LXAPI创建的回答</p><p>修改回答的内容</p>",
"comment_count":0,
"like_count":2,
"pinned_at":null,
"created_at":"2018-09-03 09:49:30",
"updated_at":"2018-09-03 09:49:30"
},
"relationships":{
"owner":{
"data":{
"type":"staff",
"id":"ThreeZhang"
}
}
}
},
{
"type":"answer",
"id":"8e39efbed95e11e692450800278acc25",
"attributes":{
"is_anonymous":0,
"content":"<p>通过LXAPI创建的回答2</p>",
"comment_count":6,
"like_count":1,
"pinned_at":null,
"created_at":"2018-09-03 04:21:30",
"updated_at":"2018-09-03 04:21:30"
},
"relationships":{
"owner":{
"data":{
"type":"staff",
"id":"FourLee"
}
}
}
},
{
"type":"answer",
"id":"2fdb18b6d8c411e6a7160800278acc25",
"attributes":{
"is_anonymous":0,
"content":"<p>通过LXAPI创建的回答2</p>",
"comment_count":6,
"like_count":0,
"pinned_at":null,
"created_at":"2018-08-20 04:46:30",
"updated_at":"2018-08-22 14:14:06"
},
"relationships":{
"owner":{
"data":{
"type":"staff",
"id":"TwoWang"
}
}
}
}
],
"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":"开发组"
}
}
]
}
参数 | 说明 |
---|---|
is_anonymous | 回答是否匿名,1表示匿名,0表示不匿名,默认为0 |
content | 回答的详细内容 |
comment_count | 回答的评论数量 |
like_count | 回答的点赞数量 |
pinned_at | 回答置的顶时间,为null 则为没有被置顶 |
created_at | 回答的创建时间 |
updated_at | 回答的更新时间 |
GET https://lxapi.lexiangla.com/cgi-bin/v1/staffs/{staff_id}/questions
支持分页参数和排序:(通用说明?)
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
staff_id | 是 | 无 | 员工帐号 |
per_page | 否 | 无 | 每页返回的数量 |
page | 否 | 无 | 当前页数 |
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get('staffs/' . $StaffID . '/questions', [
'per_page' => 2,
'page' => 2,
]);
document
{
"data": [
{
"type": "question",
"id": "a20eee760f3f11eaa6990a58ac1302c1",
"attributes": {
"title": "Holand pig",
"summary": "Holand pig",
"content": "",
"created_at": "2019-11-25 12:54:16",
"answer_count": 1,
"read_count": 15,
"concern_count": 0
}
},
{
"type": "question",
"id": "8dad6e440f3f11eabdca0a58ac1302c1",
"attributes": {
"title": "Holand pig",
"summary": "Holand pig",
"content": "",
"created_at": "2019-11-25 12:53:42",
"answer_count": 0,
"read_count": 2,
"concern_count": 0
}
}
],
"links": {
"first": "https://lxapi.lexiangla.com/cgi-bin/v1/staffs/ThreeZhang/questions?page=1",
"last": "https://lxapi.lexiangla.com/cgi-bin/v1/staffs/ThreeZhang/questions?page=1",
"prev": null,
"next": null
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 1,
"path": "https://lxapi.lexiangla.com/cgi-bin/v1/staffs/ThreeZhang/questions",
"per_page": 20,
"to": 2,
"total": 2
}
}
参数 | 说明 |
---|---|
id | 乐问id |
title | 乐问标题 |
summary | 乐问简介 |
content | 乐问内容 |
answer_count | 回答数 |
read_count | 阅读数 |
concern_count | 关注数 |
created_at | 乐问的创建时间 |
updated_at | 乐问的更新时间 |
GET https://lxapi.lexiangla.com/cgi-bin/v1/staffs/{staff_id}/answers
支持分页参数和排序:(通用说明?)
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
staff_id | 是 | 无 | 员工帐号 |
per_page | 否 | 20 | 每页返回的数量 |
page | 否 | 1 | 当前页数 |
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get('staffs/' . $staff_id . '/answers',[
'per_page' => 2,
'page' => 2,
]);
document
{
"data": [
{
"type": "answer",
"id": "5b1c19fe0f3411ea9f600a58ac1300b1",
"attributes": {
"is_anonymous": 0,
"summary": "Holand pig",
"content": "",
"comment_count": 0,
"like_count": 0,
"pinned_at": null,
"created_at": "2019-11-25 11:33:32",
"updated_at": "2019-11-25 11:33:32"
},
"relationships": {
"question": {
"data": {
"type": "question",
"id": "01ed01b00f3211ea82f75254009b5a66"
}
}
}
}
],
"links": {
"first": "https://lxapi.lexiangla.com/cgi-bin/v1/staffs/ThreeZhang/answers?page=1",
"last": "https://lxapi.lexiangla.com/cgi-bin/v1/staffs/ThreeZhang/answers?page=1",
"prev": null,
"next": null
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 1,
"path": "https://lxapi.lexiangla.com/cgi-bin/v1/staffs/ThreeZhang/answers",
"per_page": 20,
"to": 1,
"total": 1
},
"included": [
{
"type": "question",
"id": "01ed01b00f3211ea82f75254009b5a66",
"attributes": {
"title": "乐问空格测试",
"is_anonymous": 0,
"summary": "Holand pig",
"content": "",
"read_count": 15,
"answer_count": 1,
"concern_count": 0,
"created_at": "2019-11-25 11:16:44",
"updated_at": "2019-11-25 11:33:32"
}
}
]
}
参数 | 说明 |
---|---|
id | 回答id |
title | 回答标题 |
summary | 回答简介 |
content | 回答内容 |
comment_count | 评论数 |
like_count | 回答的点赞数量 |
pinned_at | 回答置的顶时间,为null 则为没有被置顶 |
created_at | 回答的创建时间 |
updated_at | 回答的更新时间 |