乐问

创建问题

接口调用说明:

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":"StaffID"
                }
            },
            "tags":{
                "data":[
                    {
                        "type":"tag",
                        "id":"db768572a5c111e89e5c10e7c61c70fc"
                    },
                    {
                        "type":"tag",
                        "id":"db76cc44a5c111e89ddb10e7c61c70fc"
                    },
                    {
                        "type":"tag",
                        "id":"db770ac4a5c111e8904e10e7c61c70fc"
                    }
                ]
            }
        }
    },
    "included":[
        {
            "type":"staff",
            "id":"StaffID",
            "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/{QuestionID}

参数说明:

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

SDK封装方法使用示例:

$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->getQuestion('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":"StaffID"
                }
            },
            "tags":{
                "data":[
                    {
                        "type":"tag",
                        "id":"db768572a5c111e89e5c10e7c61c70fc"
                    },
                    {
                        "type":"tag",
                        "id":"db76cc44a5c111e89ddb10e7c61c70fc"
                    },
                    {
                        "type":"tag",
                        "id":"db770ac4a5c111e8904e10e7c61c70fc"
                    }
                ]
            }
        }
    },
    "included":[
        {
            "type":"staff",
            "id":"StaffID",
            "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":"StaffID"
                }
            },
            "tags":{
                "data":[
                    {
                        "type":"tag",
                        "id":"db768572a5c111e89e5c10e7c61c70fc"
                    },
                    {
                        "type":"tag",
                        "id":"db76cc44a5c111e89ddb10e7c61c70fc"
                    },
                    {
                        "type":"tag",
                        "id":"db770ac4a5c111e8904e10e7c61c70fc"
                    }
                ]
            }
        }
    },
    "included":[
        {
            "type":"staff",
            "id":"StaffID",
            "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资源"
    }
}

创建回答

接口调用说明:

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

请求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":"StaffID"
                }
            }
        }
    },
    "included":[
        {
            "type":"staff",
            "id":"StaffID",
            "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":"StaffID"
                }
            }
        }
    },
    "included":[
        {
            "type":"staff",
            "id":"StaffID",
            "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":"StaffID1"
                    }
                }
            }
        },
        {
            "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":"StaffID2"
                    }
                }
            }
        },
        {
            "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":"StaffID3"
                    }
                }
            }
        }
    ],
    "included":[
        {
            "type":"staff",
            "id":"StaffID1",
            "attributes":{
                "name":"张三",
                "english_name":"ThreeZhang",
                "organization":"运营组"
            }
        },
        {
            "type":"staff",
            "id":"StaffID2",
            "attributes":{
                "name":"李四",
                "english_name":"FourLee",
                "organization":"产品组"
            }
        },
        {
            "type":"staff",
            "id":"StaffID3",
            "attributes":{
                "name":"王二",
                "english_name":"TwoWang",
                "organization":"开发组"
            }
        }
    ]
}

参数说明:

参数 说明
is_anonymous 回答是否匿名,1表示匿名,0表示不匿名,默认为0
content 回答的详细内容
comment_count 回答的评论数量
like_count 回答的点赞数量
pinned_at 回答置的顶时间,为null则为没有被置顶
created_at 回答的创建时间
updated_at 回答的更新时间