Notifications
Note
此页面的内容需要进行重大更新。旧页面包含过时且可能不准确的信息。您仍然可以在 Mautic Developer Documentation archived repository 中访问它。
如果您有兴趣帮助开发此页面和其他新内容的,请考虑加入文档编写工作。
请阅读 Contributing Guidelines 和 Contributing to Mautic’s documentation 以开始您的贡献。
使用此端点获取有关 Mautic 通知的信息。
<?php
use Mautic\MauticApi;
use Mautic\Auth\ApiAuth;
// ...
$initAuth = new ApiAuth();
$auth = $initAuth->newAuth($settings);
$apiUrl = "https://example.com";
$api = new MauticApi();
$notificationApi = $api->newApi("notifications", $auth, $apiUrl);
获取通知
<?php
//...
$notification = $notificationApi->get($id);
通过 ID 获取单个通知。
HTTP 请求
GET /notifications/ID
响应
Expected Response Code: 200
{
"notification":{
"isPublished":true,
"dateAdded":"2016-09-14T14:03:05+00:00",
"createdBy":1,
"createdByUser":"John Doe",
"dateModified":"2016-09-15T08:40:46+00:00",
"modifiedBy":1,
"modifiedByUser":"John Doe",
"id":1,
"name":"The first notification",
"heading":"The first notification Heading",
"message":"The first notification Message",
"url":"http:\/\/mautic.org",
"language":"en",
"category":null,
"publishUp":null,
"publishDown":null,
"readCount":0,
"sentCount":0
}
}
通知属性
- Name
Type
Description
idint
通知 ID
namestring
通知标题
headingstring
通知头部
messagestring
通知内容
urlstring
当点击通知时跳转的 URL
isPublishedboolean
发布状态
publishUpdatetime/null
通知发布日期/时间
publishDowndatetime/null
通知取消发布日期/时间
dateAddeddatetime创建通知的日期/时间
createdByint
创建通知的用户 ID
createdByUserstring
创建通知用户的姓名
dateModifieddatetime/null
最后修改通知的日期/时间
modifiedByint
最后修改通知的用户 ID
modifiedByUserstring
最后修改通知用户的姓名
languagestring
语言区域设置
readCountint
通知总阅读次数
sentCountint
唯一通知发送次数
categorynull/object
分类
列出通知
<?php
// ...
$notifications = $notificationApi->getList($searchFilter, $start, $limit, $orderBy, $orderByDir, $publishedOnly, $minimal);
HTTP 请求
GET /notifications
查询参数
Name |
Description |
|---|---|
|
用于过滤实体的字符串或搜索命令。 |
|
返回实体的起始行。默认为 0。 |
|
要返回的实体数量限制。默认为分页系统的配置 - 默认为 30 |
|
用于排序的列。可以使用响应中列出的任何列。 |
|
排序方向: |
|
仅返回当前已发布的实体。 |
|
仅返回实体数组,不包含其他列表。 |
响应
Expected Response Code: 200
“total”:1, “notifications”:[
- {
“isPublished”:true, “dateAdded”:”2016-09-14T14:03:05+00:00”, “createdBy”:1, “createdByUser”:”John Doe”, “dateModified”:”2016-09-15T08:40:46+00:00”, “modifiedBy”:1, “modifiedByUser”:”John Doe”, “id”:1, “name”:”The first notification”, “heading”:”The first notification Heading”, “message”:”The first notification Message”, “url”:”http://mautic.org”, “language”:”en”, “category”:null, “publishUp”:null, “publishDown”:null, “readCount”:0, “sentCount”:0
}
]
}
Properties
Same as Get Notification.
Create notification
<?php
$data = array(
'name' => 'Notification A',
'heading' => 'Hello World!'
'message' => 'This is my first notification created via API.',
);
$notification = $notificationApi->create($data);
Create a new notification.
HTTP Request
POST /notifications/new
POST Parameters
Name |
Type |
Description |
|---|---|---|
|
int |
ID of the notification |
|
string |
Title of the notification |
|
string |
Heading of the notification |
|
string |
Message of the notification |
|
string |
URL to go to when the notification gets clicked |
|
boolean |
Published state |
|
datetime/null |
Notification publish date/time |
|
datetime/null |
Notification unpublish date/time |
|
string |
Language locale of the notification |
Response
Expected Response Code: 201
Properties
Same as Get Notification.
Edit notification
<?php
$id = 1;
$data = array(
'name' => 'Notification A',
'heading' => 'Hello World!'
'message' => 'This is my first notification created via API.',
);
// Create new a notification of ID 1 isn't found?
$createIfNotFound = true;
$notification = $notificationApi->edit($id, $data, $createIfNotFound);
Edit a new notification. Note that this supports PUT or PATCH depending on the desired behavior.
PUT creates a notification if the given ID doesn’t exist and clears all the notification information, adds the information from the request. PATCH fails if the notification with the given ID doesn’t exist and updates the notification field values with the values from the request.
HTTP Request
要编辑通知并返回 404 错误(如果未找到该通知):
PATCH /notifications/ID/edit
要编辑通知,如果未找到该通知,则创建一个新通知:
PUT /notifications/ID/edit
POST 参数
Name |
Type |
Description |
|---|---|---|
|
int |
通知 ID |
|
string |
通知标题 |
|
string |
通知头部 |
|
string |
通知消息 |
|
string |
当点击通知时跳转的 URL |
|
boolean |
发布状态 |
|
datetime/null |
通知发布日期/时间 |
|
datetime/null |
通知取消发布日期/时间 |
|
string |
语言本地化设置 |
响应
如果使用 PUT,则预期响应代码为 `200`(如果已编辑通知)或 `201`(如果已创建)。
如果使用 PATCH,则预期响应代码为 200。
属性
删除通知
<?php
$notification = $notificationApi->delete($id);
删除一个通知。
HTTP 请求
DELETE /notifications/ID/delete
响应
Expected Response Code: 200
属性