跳到内容

以用户为中心的 API

registerUser

Anchor link to

POST https://api.pushwoosh.com/json/1.3/registerUser

将外部 User ID 与指定设备关联。

名称必需描述
AuthorizationToken XXXX用于访问 Device API 的 API Device Token。请将 XXXX 替换为您的实际 Device API token。
名称必需类型描述
userIdstring用于与设备关联的 User ID。如果为空,则使用 hwid。
applicationstringPushwoosh application code
hwidstringPushwoosh HWID
tz_offsetinteger设备的秒级时区偏移量。
device_typeinteger设备类型。请在 /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 to

POST https://api.pushwoosh.com/api/v2/device-api/deleteUser

删除一个用户以及与该应用程序中指定的 User ID 关联的所有设备。该请求是异步处理的,一旦删除请求被接受处理,端点就会返回 200 OK

名称必需描述
AuthorizationToken XXXX用于访问 Device API 的 API Device Token。请将 XXXX 替换为您的实际 Device API token。
Content-Typeapplication/json
名称必需类型描述
applicationstringPushwoosh application code
user_idstring要删除的 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描述
200200删除请求已接受
200210参数错误。请参阅 status_message 了解更多信息。
400N/A请求字符串格式错误
401N/A缺少或无效的 Authorization token
500500内部错误

POST https://api.pushwoosh.com/json/1.3/postEvent

触发一个事件。

名称必需描述
AuthorizationToken XXXX用于访问 Device API 的 API Device Token。请将 XXXX 替换为您的实际 Device API token。
名称必需类型描述
hwidstring在 /registerDevice 请求中使用的 Hardware device ID。可与 ‘userId’ 一起使用,以识别触发事件的用户。
applicationstringPushwoosh application code
eventstringEvent name 必须与在 Pushwoosh Control Panel 中创建的完全一致。
attributesobject包含事件属性的 JSON 对象。如果无需传递属性,请将其留空。
timestampUTCintegerUTC 时间戳。
timestampCurrentinteger本地时间时间戳。
userIdstring与触发事件的用户关联的 User ID。可被 HWID 替换或与 HWID 一起使用。
device_typeinteger查看可能的值

请求中的事件名称必须与 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"
}
}

发送转化事件

Anchor link to

要直接报告收入而不是映射现有事件,请发送 postEvent,并将 PW_Conversion 作为事件名称,将交易的 valuecurrency 放在 attributes 中:

{
"request":{
"hwid": "8f65b16df378e7a6bece9614e1530fb2",
"application": "XXXXX-XXXXX",
"event": "PW_Conversion",
"attributes": {
"value": 49.99, // required. Transaction amount
"currency": "USD", // required. ISO 4217 currency code
"transaction_id": "txn_8f21", // optional. Your own transaction reference
"product_id": "prod_premium" // optional
},
"userId": "someuser@user.com"
}
}