[comment]: # ({1cabb47e-0fc7ba20})
# 连接器获取

[comment]: # ({/1cabb47e-0fc7ba20})

[comment]: # ({efd10e48-c152f697})
### 描述

`integer/array connector.get(object parameters)`

该方法允许根据给定的参数检索连接器 objects。

::: noteclassic
此方法仅适用于*超级管理员*用户类型。调用该方法的权限可以在用户角色设置中撤销。
更多信息请参见 [User roles](/manual/web_interface/frontend_sections/users/user_roles)。
:::

[comment]: # ({/efd10e48-c152f697})

[comment]: # ({0ecbb97e-b096237f})
### 参数

`(object)` 定义所需输出的参数。

该方法支持以下参数。

|Parameter|[Type](/manual/api/reference_commentary#data-types)|Description|
|--|--|------|
|connectorids|ID/array|仅返回具有给定 ID 的 connectors。|
|selectTags|query|返回一个 `tags` 属性，其中包含 connector [tag filter](/manual/api/reference/connector/object#tag-filter)。<br><br>支持 `count`。|
|sortfield|string/array|按给定属性对结果排序。<br><br>可能的值：`connectorid`、`name`、`data_type`、`status`。|
|countOutput|boolean|这些参数在[参考说明](/manual/api/reference_commentary#common-get-method-parameters)中有描述。|
|excludeSearch|boolean|^|
|filter|object|^|
|limit|integer|^|
|output|query|^|
|preservekeys|boolean|^|
|search|object|^|
|searchByAny|boolean|^|
|searchWildcardsEnabled|boolean|^|
|sortorder|string/array|^|
|startSearch|boolean|^|

[comment]: # ({/0ecbb97e-b096237f})

[comment]: # ({fbd15acf-830d8762})
### 返回值

`(integer/array)` 返回以下之一：

- 一个 array 的 objects；
- 检索到的 objects 的数量，如果使用了 `countOutput` 参数。

[comment]: # ({/fbd15acf-830d8762})

[comment]: # ({b41637d2-122d6c45})
### 示例

[comment]: # ({/b41637d2-122d6c45})

[comment]: # ({75b302a6-3a1b6d17})
#### 获取所有连接器

检索所有连接器及其属性的所有数据。

[执行请求](/manual/api#执行请求):


```json
{
    "jsonrpc": "2.0",
    "method": "connector.get",
    "params": {
        "output": "extend",
        "selectTags": ["tag", "operator", "value"],
        "preservekeys": true
    },
    "id": 1
}
```
响应：


```json
{
    "jsonrpc": "2.0",
    "result": [
        {
            "connectorid": "1",
            "name": "Export of item values",
            "protocol": "0",
            "data_type": "0",
            "url": "{$DATA_EXPORT_VALUES_URL}",
            "item_value_type": "31",
            "authtype": "4",
            "username": "{$DATA_EXPORT_VALUES_USERNAME}",
            "password": "{$DATA_EXPORT_VALUES_PASSWORD}",
            "token": "",
            "max_records": "0",
            "max_senders": "4",
            "max_attempts": "2",
            "attempt_interval": "10s",
            "timeout": "10s",
            "http_proxy": "{$DATA_EXPORT_VALUES_PROXY}",
            "verify_peer": "1",
            "verify_host": "1",
            "ssl_cert_file": "{$DATA_EXPORT_VALUES_SSL_CERT_FILE}",
            "ssl_key_file": "{$DATA_EXPORT_VALUES_SSL_KEY_FILE}",
            "ssl_key_password": "",
            "description": "",
            "status": "1",
            "tags_evaltype": "0",
            "tags": [
                {
                    "tag": "component",
                    "operator": "0",
                    "value": "memory"
                }
            ]
        },
        {
            "connectorid": "2",
            "name": "Export of events",
            "protocol": "0",
            "data_type": "1",
            "url": "{$DATA_EXPORT_EVENTS_URL}",
            "item_value_type": "31",
            "authtype": "5",
            "username": "",
            "password": "",
            "token": "{$DATA_EXPORT_EVENTS_BEARER_TOKEN}",
            "max_records": "0",
            "max_senders": "2",
            "max_attempts": "1",
            "attempt_interval": "5s",
            "timeout": "5s",
            "http_proxy": "",
            "verify_peer": "1",
            "verify_host": "1",
            "ssl_cert_file": "",
            "ssl_key_file": "",
            "ssl_key_password": "",
            "description": "",
            "status": "1",
            "tags_evaltype": "0",
            "tags": [
                {
                    "tag": "scope",
                    "operator": "0",
                    "value": "performance"
                }
            ]
        }
    ],
    "id": 1
}
```

[comment]: # ({/75b302a6-3a1b6d17})

[comment]: # ({572555ee-4963c0b1})
### 来源

CConnector::get() 方法位于 *ui/include/classes/api/services/CConnector.php* 文件中。

[comment]: # ({/572555ee-4963c0b1})
