[comment]: # ({82eb5968-16011390})
# 获取

[comment]: # ({/82eb5968-16011390})

[comment]: # ({4163a351-652fd3aa})
### Description 描述

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

The method allows to retrieve media types according to the given
parameters. 此方法用于检索给定参数和符合条件的媒介类型

[comment]: # ({/4163a351-652fd3aa})

[comment]: # ({3a1a73e4-cef19550})
### Parameters 参数

`(object)` Parameters defining the desired output. `(object)`
定义所需输出的参数。

The method supports the following parameters. 此方法支持一下参数。

|Parameter|Type|Description|
|---------|----|-----------|
|mediatypeids|string/array|Return only media types with the given IDs. 仅返回所给IDs的媒介类型|
|mediaids|string/array|Return only media types used by the given media. 只返回给定媒体使用的媒介类型。|
|userids|string/array|Return only media types used by the given users. 只返回给定用户使用的媒介类型。|
|selectUsers|query|Return the users that use the media type in the `users` property. 返回`users`属性中使用媒介类型的用户。|
|sortfield|string/array|Sort the result by the given properties.<br><br>Possible values are: `mediatypeid`. 根据给定的属性对结果进行排序。<br><br>可能的值是: `mediatypeid`|
|countOutput|boolean|These parameters being common for all `get` methods are described in detail in the [reference commentary](/manual/api/reference_commentary#common_get_method_parameters). 这些参数对于所有的“get”方法都是通用的[reference commentary](/manual/api/reference_commentary#common_get_method_parameters)|
|editable|boolean|^|
|excludeSearch|boolean|^|
|filter|object|^|
|limit|integer|^|
|output|query|^|
|preservekeys|boolean|^|
|search|object|^|
|searchByAny|boolean|^|
|searchWildcardsEnabled|boolean|^|
|sortorder|string/array|^|
|startSearch|boolean|^|

[comment]: # ({/3a1a73e4-cef19550})

[comment]: # ({be32ca86-7223bab1})
### Return values

`(integer/array)` Returns either:返回如下：

-   an array of objects;
-   the count of retrieved objects, if the `countOutput` parameter has
    been used.
-   一个对象数组；
-   如果使用了“countOutput”参数，则检索对象的计数。

[comment]: # ({/be32ca86-7223bab1})

[comment]: # ({7b785443-b41637d2})
### Examples 示例如下

[comment]: # ({/7b785443-b41637d2})

[comment]: # ({cc7389cc-083b740b})
#### Retrieving media types 检索媒介类型

Retrieve all configured media types. 检索所有配置的媒介类型

Request:

``` {.java}
{
    "jsonrpc": "2.0",
    "method": "mediatype.get",
    "params": {
        "output": "extend"
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

``` {.java}
{
    "jsonrpc": "2.0",
    "result": [
        {
            "mediatypeid": "1",
            "type": "0",
            "description": "Email",
            "smtp_server": "mail.company.com",
            "smtp_helo": "company.com",
            "smtp_email": "zabbix@company.com",
            "exec_path": "",
            "gsm_modem": "",
            "username": "",
            "passwd": "",
            "status": "0",
            "maxsessions": "1",
            "maxattempts": "7",
            "attempt_interval": "10s"
        },
        {
            "mediatypeid": "2",
            "type": "3",
            "description": "Jabber",
            "smtp_server": "",
            "smtp_helo": "",
            "smtp_email": "",
            "exec_path": "",
            "gsm_modem": "",
            "username": "jabber@company.com",
            "passwd": "zabbix",
            "status": "0",
            "maxsessions": "1",
            "maxattempts": "7",
            "attempt_interval": "10s"
        },
        {
            "mediatypeid": "3",
            "type": "2",
            "description": "SMS",
            "smtp_server": "",
            "smtp_helo": "",
            "smtp_email": "",
            "exec_path": "",
            "gsm_modem": "/dev/ttyS0",
            "username": "",
            "passwd": "",
            "status": "0",
            "maxsessions": "1",
            "maxattempts": "7",
            "attempt_interval": "10s"
        }
    ],
    "id": 1
}
```

[comment]: # ({/cc7389cc-083b740b})

[comment]: # ({039ccba1-039ccba1})
### See also

-   [User](/manual/api/reference/user/object#user)

[comment]: # ({/039ccba1-039ccba1})

[comment]: # ({4e8a6036-4e8a6036})
### Source

CMediaType::get() in
*frontends/php/include/classes/api/services/CMediaType.php*.

[comment]: # ({/4e8a6036-4e8a6036})
