以用户为中心的 API
registerUser
Anchor link toPOST https://api.pushwoosh.com/json/1.3/registerUser
将外部 User ID 与指定设备关联。
| 名称 | 必需 | 值 | 描述 |
|---|---|---|---|
| Authorization | 是 | Token XXXX | 用于访问 Device API 的 API Device Token。请将 XXXX 替换为您的实际 Device API token。 |
| 名称 | 必需 | 类型 | 描述 |
|---|---|---|---|
| userId | 否 | string | 要与设备关联的 User ID。如果为空,则使用 hwid。 |
| application | 是 | string | Pushwoosh application code |
| hwid | 是 | string | Pushwoosh HWID |
| tz_offset | 否 | integer | 设备的秒级时区偏移量。 |
| device_type | 否 | integer | 设备类型。请参阅 /registerDevice 中的可能值。 |
稍后可在 /createMessage API 调用(users 参数)中使用。
您可以在拥有 push token 之前以及在调用 /registerDevice 之前调用此函数。
请求示例
Anchor link to{ "request": { "userId": "user_3078a", // optional. If empty, use hwid "application": "XXXXX-XXXXX", // required. Pushwoosh application code "hwid": "8f65b16df378e7a6bece9614e1530fb2", // required. Hardware device ID "tz_offset": -3600, // optional. Timezone offset in seconds "device_type": 3 // optional. Device type, see /registerDevice // for device types }}响应示例
Anchor link to{ "status_code": 200, "status_message": "OK", "response": null}deleteUser
Anchor link toPOST https://api.pushwoosh.com/api/v2/device-api/deleteUser
删除用户以及与应用程序内指定的 User ID 关联的所有设备。该请求是异步处理的,一旦删除请求被接受处理,端点就会返回 200 OK。
| 名称 | 必需 | 值 | 描述 |
|---|---|---|---|
| Authorization | 是 | Token XXXX | 用于访问 Device API 的 API Device Token。请将 XXXX 替换为您的实际 Device API token。 |
| Content-Type | 是 | application/json |
| 名称 | 必需 | 类型 | 描述 |
|---|---|---|---|
| application | 是 | string | Pushwoosh application code |
| user_id | 是 | string | 要删除的 User ID。与此用户在指定应用程序中关联的所有设备都将被移除。 |
请求示例
Anchor link to{ "application": "XXXXX-XXXXX", // required. Pushwoosh application code "user_id": "user_3078a" // required. User ID to delete}响应示例
Anchor link to{ "status_code": 200, "status_message": "OK", "response": null}| HTTP 状态码 | status_code | 描述 |
|---|---|---|
| 200 | 200 | 删除请求已接受 |
| 200 | 210 | 参数错误。请参阅 status_message 了解更多信息。 |
| 400 | N/A | 请求字符串格式错误 |
| 401 | N/A | 缺少或无效的 Authorization token |
| 500 | 500 | 内部错误 |
postEvent
Anchor link toPOST https://api.pushwoosh.com/json/1.3/postEvent
触发一个事件。
| 名称 | 必需 | 值 | 描述 |
|---|---|---|---|
| Authorization | 是 | Token XXXX | 用于访问 Device API 的 API Device Token。请将 XXXX 替换为您的实际 Device API token。 |
| 名称 | 必需 | 类型 | 描述 |
|---|---|---|---|
| hwid | 是 | string | 在 /registerDevice 请求中使用的 Hardware device ID。可与 ‘userId’ 一起使用,以识别触发事件的用户。 |
| application | 是 | string | Pushwoosh application code |
| event | 是 | string | 事件名称,与在 Pushwoosh Control Panel 中创建的完全一致。 |
| attributes | 是 | object | 包含事件属性的 JSON 对象。如果不需要传递任何属性,请将其留空。 |
| timestampUTC | 否 | integer | UTC 时间戳。 |
| timestampCurrent | 否 | integer | 本地时间的时间戳。 |
| userId | 是 | string | 与触发事件的用户关联的 User ID。可以替换或与 HWID 一起使用。 |
| device_type | 否 | integer | 查看可能的值 |
请求中的事件名称必须与 Pushwoosh Control Panel 中的事件名称匹配。请注意,如果事件没有属性,“attributes” 属性可以为空(但不能省略)。
请求示例
Anchor link to{ "request":{ "hwid": "8f65b16df378e7a6bece9614e1530fb2", // required. Hardware device ID used in a /registerDevice API. // Can be used along with an userId to identify a // user who has triggered an event. "application": "XXXXX-XXXXX", // required. Pushwoosh application code "event": "activityCompleted", // required. Event name exactly as created in Pushwoosh Control Panel "attributes": { // required. Leave empty if no attributes need to be passed. "login": "facebook", "success": "yes", "internet": "wifi" }, "timestampUTC": 1435228403, // optional. Timestamp in UTC "timestampCurrent": 1435253603, // optional. Timestamp in local time "userId": "someuser@user.com", // required. A user id which is used for identification of // users on multiple devices. Can be replaced by // or used along with an HWID. "device_type": 1 // optional. }}响应示例
Anchor link to{ "status_code": 200, "status_message": "OK", "response": { "code": "61BC9-84DD0" }}