跳到内容

User centric API

registerUser

Anchor link to

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

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

Request headers

Anchor link to
名称必填描述
AuthorizationToken XXXX用于访问 Device API 的 API Device Token。将 XXXX 替换为您实际的 Device API token。

Request body

Anchor link to
名称类型描述
userIdstring要与设备关联的 User ID。如果为空,则使用 hwid。
application*stringPushwoosh application code
hwid*stringPushwoosh HWID
tz_offsetinteger设备的以秒为单位的时区偏移量。
device_typeintegerDevice type。查看 /registerDevice 中的可能值。
{
"status_code": 200,
"status_message": "OK",
"response": null
}

稍后可在 /createMessage API 调用中使用(users 参数)。
通常在获取 push token 之前和调用 /registerDevice 之前调用此函数。

Example
{
"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
}
}

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

发送事件。

Request headers

Anchor link to
名称必填描述
AuthorizationToken XXXX用于访问 Device API 的 API Device Token。将 XXXX 替换为您实际的 Device API token。

Request body

Anchor link to
名称类型描述
hwid*string在 /registerDevice 请求中使用的 Hardware device ID。可与 ‘userId’ 一起使用,以识别触发事件的用户。
application*stringPushwoosh application code
event*string在 Pushwoosh Control Panel 中创建的 Event name(完全一致)。
attributes*object包含事件属性的 JSON 对象。如果不需要传递属性,请将其留空。
timestampUTCintegerUTC 时间戳。
timestampCurrentinteger本地时间的时间戳。
userId*string与触发事件的用户关联的 User ID。可以替换为 HWID 或与 HWID 一起使用。
device_typeinteger查看可能的值
{
"status_code": 200,
"status_message": "OK",
"response": {
"code": "61BC9-84DD0"
}
}

请求中的事件名称必须与 Pushwoosh Control Panel 中的事件名称匹配。请注意,如果事件没有属性,“attributes” 属性可以为空(但不能省略)。

Example
{
"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.
}
}