# 乐问

# 创建问题

# 接口调用说明:

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 问题标签,必须为数组

# SDK封装方法使用示例:

$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$attributs = [
    'title' => 'API创建的乐问标题',
    'content' => '<p>PHP是最好的语言</p>',
    'is_anonymous' => 0,
    'tags' => ['PHP', '乐问', 'API'],
];
$response = $Lxapi->postQuestion(StaffID, $attributs);

# 响应document

# 201 Created 状态码
{
    "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

# 参数说明:

参数 是否必须 默认值 说明
filter 若值为 hot,则拉取热问列表。否则列表按创建时间倒叙
date_range 7 仅当 filter=hot 时有效,表示拉取n天内的热门问题,默认值为7天
tag_name 通过标签名筛选乐问问题

# SDK封装方法使用示例:

$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get('questions?filter=hot&date_range=3');
// $response = $Lxapi->get('questions?tag_name=福利');

# 获取单个问题详情

# 接口调用说明:

GET https://lxapi.lexiangla.com/cgi-bin/v1/questions/{QuestionID}

# 参数说明:

参数 是否必须 默认值 说明
QuestionID question中资源对象类型为question的资源对象ID,即乐问ID

# SDK封装方法使用示例:

$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get('questions/c217bd40916b11e88bf75254009b5a66');

# 响应document

# 200 OK 状态码
{
    "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"
            }
        }
    ]
}
# 404 Not Found 状态码
{
    "errors":{
        "detail":"不存在ID为`c217bd40916b11e88bf75254009b5a26`的question资源"
    }
}

# 更新问题

# 接口调用说明:

PATCH https://lxapi.lexiangla.com/cgi-bin/v1/questions/{QuestionID}

# 请求document

{
    "data":{
        "type":"question",
        "attributes":{
            "title":"API创建的乐问标题,修改乐问的标题",
            "content":"<p>PHP是最好的语言</p>",
            "tags":[
                "PHP",
                "乐问",
                "API"
            ]
        }
    }
}

# 参数说明:

参数 是否必须 默认值 说明
QuestionID 资源对象类型为question的资源对象ID,即乐问ID
type 资源对象类型,必须为 question,表示问题
question.title 乐问标题,最大长度为100字节
question.content 乐问内容,可以为富文本内容
question.tags 问题标签,必须为数组

# SDK封装方法使用示例:

$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$attributes = [
    'title' => 'API创建的乐问标题,修改乐问的标题',
    'content' => '<p>PHP是最好的语言</p>',
    'tags' => ['PHP', '乐问', 'API'],
];
$response = $Lxapi->patchQuestion(StaffID,'65b0f088a5c211e8ac0b10e7c61c70fc', $attributes);

# 响应document

# 200 OK 状态码
{
    "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"
            }
        }
    ]
}
# 404 Not Found 状态码
{
    "errors":{
        "detail":"不存在ID为`65b0f088a5c211e8ac0b10e7c61c70f2`的question资源"
    }
}

# 删除问题

# 接口调用说明:

DELETE https://lxapi.lexiangla.com/cgi-bin/v1/questions/{QuestionID}

# 参数说明:

参数 是否必须 默认值 说明
QuestionID 资源对象类型为question的资源对象ID,即乐问ID

# SDK封装方法使用示例:

$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->deleteQuestion(StaffID, '65b0f088a5c211e8ac0b10e7c61c70fc');

# 响应document

# 204 No Content 状态码
[]
# 404 Not Found 状态码
{
    "errors":{
        "detail":"不存在ID为`65b0f088a5c211e8ac0b10e7c61c70ff`的question资源"
    }
}

# 创建回答

# 接口调用说明:

POST https://lxapi.lexiangla.com/cgi-bin/v1/questions/{QuestionID}/answers

# 请求document

{
    "data":{
        "type":"answer",
        "attributes":{
            "content":"<p>通过LXAPI创建的回答</p>",
            "is_anonymous":0
        }
    }
}

# 参数说明:

参数 是否必须 默认值 说明
QuestionID question中资源对象类型为question的资源对象ID,即乐问ID
type 资源对象类型,必须为answer,表示乐问回答
answer.content 回答的内容,支持富文本内容
answer.is_anonymous 是否匿名回答,1表示匿名,0表示不匿名

# SDK封装方法使用示例:

$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$attributes = [
    'content' => '<p>通过LXAPI创建的回答</p>',
    'is_anonymous' => 0,
];
$response = $Lxapi->postQuestionAnswer(StaffID, '65b0f088a5c211e8ac0b10e7c61c70fc', $attributes);

# 响应document

# 201 Created 状态码
{
    "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":"运营组"
            }
        }
    ]
}
# 404 Not Found 状态码
{
    "errors":{
        "detail":"不存在ID为`65b0f088a5c211e8ac0b10e7c61c70f2`的question资源"
    }
}

# 更新回答

# 接口调用说明:

PATCH https://lxapi.lexiangla.com/cgi-bin/v1/questions/{QuestionID}/answers/{AnswerID}

# 请求document

{
    "data":{
        "type":"answer",
        "attributes":{
            "content":"<p>通过LXAPI创建的回答</p><p>修改回答的内容</p>"
        }
    }
}

# 参数说明:

参数 是否必须 默认值 说明
QuestionID 资源对象类型为question的资源对象ID,即乐问ID
AnswerID 资源对象类型为answer的资源对象ID,即乐问回答ID
type 资源对象类型,必须为answer,表示乐问回答
answer.content 回答的内容,支持富文本内容

# SDK封装方法使用示例:

$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$attributes = [
    'content' => '<p>通过LXAPI创建的回答</p><p>修改回答的内容</p>',
];
$response = $Lxapi->patchQuestionAnswer(StaffID, '65b0f088a5c211e8ac0b10e7c61c70fc', '56fdb4faa5c611e89baa10e7c61c70ff', $attributes);

# 响应document

# 200 OK 状态码
{
    "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":"运营组"
            }
        }
    ]
}
# 404 Not Found 状态码
{
    "errors":{
        "detail":"不存在ID为`56fdb4faa5c611e89baa10e7c61c70ff`的answer资源"
    }
}

# 删除回答

# 接口调用说明:

DELETE https://lxapi.lexiangla.com/cgi-bin/v1/questions/{QuestionID}/answers/{AnswerID}

# 请求document

[]

# 参数说明:

参数 是否必须 默认值 说明
QuestionID 资源对象类型为question的资源对象ID,即乐问ID
AnswerID 资源对象类型为answer的资源对象ID,即乐问回答ID

# SDK封装方法使用示例:

$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->deleteQuestionAnswer(StaffID, '65b0f088a5c211e8ac0b10e7c61c70fc', '56fdb4faa5c611e89baa10e7c61c70fc');

# 响应document

# 204 No Content 状态码
[]
# 404 Not Found 状态码
{
    "errors":{
        "detail":"不存在ID为`56fdb4faa5c611e89baa10e7c61c70ff`的answer资源"
    }
}

# 回答列表

# 接口调用说明:

GET https://lxapi.lexiangla.com/cgi-bin/v1/questions/QuestionID/answers

# 参数说明:

支持分页参数和排序:(通用说明?

参数 是否必须 默认值 说明
QuestionID 问题的ID

# SDK封装方法使用示例:

#

$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get('questions/65b0f088a5c211e8ac0b10e7c61c70fc/answers');

# 响应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/{StaffID}/questions

# 参数说明:

支持分页参数和排序:(通用说明?

参数 是否必须 默认值 说明
StaffID 员工ID

# SDK封装方法使用示例:

#

$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get('staffs/ThreeZhang/questions');

# 响应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/{StaffID}/answers

# 参数说明:

支持分页参数和排序:(通用说明?

参数 是否必须 默认值 说明
StaffID 员工ID

# SDK封装方法使用示例:

#

$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get('staffs/ThreeZhang/answers');

# 响应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 回答的更新时间