搜索

通过开放接口获取的搜索内容与页面获取的内容有所不同,通过此开放接口获取的内容列表不会提示实体内容保密

若开发者需要隐藏保密实体的标题,可根据返回列表中的privilege_type字段以及关联实体team中的team.is_secret自行过滤。

$can_show = $doc->privilege_type==0 && $doc->team->is_secret==0;

接口调用说明:

GET https://lxapi.lexiangla.com/cgi-bin/v1/search?type={type}&keyword={keyword}

参数说明:

参数 是否必须 默认值 说明
type 表示要搜索的资源类型,目前只支持 doc
keyword 要搜索的关键字

SDK封装方法使用示例:

$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$file_path =  '/path/to/测试.xlsx'; // 文件的绝对路径
$response = $Lxapi->get('search?type=doc&keyword=打印机&page=2&per_page=2');

响应document

200 OK 状态码
{
    "meta": {
        "current_page": 2, 
        "from": 3, 
        "last_page": 8, 
        "path": "https://lxapi.lexiangla.com/cgi-bin/v1/search", 
        "per_page": 2, 
        "to": 4, 
        "total": 15
    }, 
    "links": {
        "first": {
            "href": "https://lxapi.lexiangla.com/cgi-bin/v1/search?page=1"
        }, 
        "last": {
            "href": "https://lxapi.lexiangla.com/cgi-bin/v1/search?page=8"
        }, 
        "prev": {
            "href": "https://lxapi.lexiangla.com/cgi-bin/v1/search?page=1"
        }, 
        "next": {
            "href": "https://lxapi.lexiangla.com/cgi-bin/v1/search?page=3"
        }
    }, 
    "data": [
        {
            "type": "doc", 
            "id": "cc3ffd04bda811e9aef22369af6c5efd", 
            "links": {
                "platform": {
                    "href": "https://lxapi.lexiangla.com/docs/cc3ffd04bda811e9aef22369af6c5efd"
                }
            }, 
            "attributes": {
                "name": "123", 
                "privilege_type": "0", 
                "is_star": "0", 
                "created_at": "2019-08-13 17:00:29", 
                "read_count": "0", 
                "comment_count": "0", 
                "updated_at": "2019-08-13 17:00:29", 
                "recommended_at": null
            }, 
            "relationships": {
                "owner": {
                    "data": {
                        "type": "staff", 
                        "id": "STAFF1"
                    }
                }, 
                "category": {
                    "data": {
                        "type": "category", 
                        "id": "9dfad0f22b1711e7a8720800278acc25"
                    }
                }
            }
        }, 
        {
            "type": "doc", 
            "id": "abbffb7ebda811e9959761aef4b83b76", 
            "links": {
                "platform": {
                    "href": "https://lxapi.lexiangla.com/docs/abbffb7ebda811e9959761aef4b83b76"
                }
            }, 
            "attributes": {
                "name": "123", 
                "privilege_type": "0", 
                "is_star": "0", 
                "created_at": "2019-08-13 16:59:34", 
                "read_count": "0", 
                "comment_count": "0", 
                "updated_at": "2019-08-13 16:59:34", 
                "recommended_at": null
            }, 
            "relationships": {
                "owner": {
                    "data": {
                        "type": "staff", 
                        "id": "STAFF1"
                    }
                }, 
                "category": {
                    "data": {
                        "type": "category", 
                        "id": "9dfad0f22b1711e7a8720800278acc25"
                    }
                }
            }
        }
    ], 
    "included": [
        {
            "type": "staff", 
            "id": "STAFF1", 
            "attributes": {
                "name": "张三", 
                "english_name": "ThreeZhang"
            }
        }, 
        {
            "type": "category", 
            "id": "9dfad0f22b1711e7a8720800278acc25", 
            "attributes": {
                "name": "后台技术"
            }
        }
    ]
}