Messages API
createMessage
Anchor link toPOST https://api.pushwoosh.com/json/1.3/createMessage
สร้าง push notification ใหม่
Request Body
Anchor link to| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
| auth* | string | API access token จาก Pushwoosh Control Panel |
| application* | string | Pushwoosh application code |
| notifications* | array | อาร์เรย์ JSON ของพารามิเตอร์ข้อความ ดูรายละเอียดในตัวอย่างคำขอด้านล่าง |
{ "status_code": 200, "status_message": "OK", "response": { "Messages": [ "C3F8-C3863ED4-334AD4F1" ] }}ตัวอย่างคำขอ
Anchor link to{ "request": { "application": "XXXXX-XXXXX", // required. Pushwoosh application code. "auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel. "notifications": [{ "send_date": "now", // optional. YYYY-MM-DD HH:mm OR 'now' "content": { // optional. object OR string. "en": "English", // Use "wns_content" instead for Windows. "fr": "French" }, "title": { // optional. object OR string. "en": "Title", // Ignored if platform-specific titles are specified "fr": "Titre" // 'ios_title', 'android_header', etc. }, // see the platform-specific parameters examples below. "subtitle":{ // optional. object OR string. "en": "Subtitle", // Ignored if platform-specific titles are specified "fr": "Sous-titre" // 'ios_subtitle', etc. }, // see the platform-specific parameters examples below. "ignore_user_timezone": true, // optional. "timezone": "America/New_York", // optional. If ignored UTC-0 is default for "send_date". // See https://php.net/manual/timezones.php for // supported timezones. "campaign": "CAMPAIGN_CODE", // optional. Campaign code to which you want to // assign this push message. "geozone": { // optional. Send to Geozone "lat": 22.22, "lng": 33.33, "range": 110 }, "rich_media": "XXXXX-XXXXX", // optional. Copy the Rich Media code from the URL bar of // the Rich Media editor page in Pushwoosh Control Panel. "link": "https://google.com", // optional. For deeplinks add "minimize_link": 0 "minimize_link": 0, // optional. 0 — do not minimize, 2 — bitly. Default = 2. // Please note that shorteners have restrictions // on a number of calls. "data": { // optional. JSON string or JSON object, will be passed as "key": "value" // "u" parameter in the payload (converted to JSON string). }, "transactionId": "unique UUID", // optional. Unique message identifier to prevent duplicating // in case of network problems. Stored on the side of // Pushwoosh for 5 minutes. "platforms": [ // optional. 1 — iOS; 3 — Android; 7 — Mac OS X; 8 — Windows; 1, 3, 7, 8, 9, 10, // 9 — Amazon; 10 — Safari; 11 — Chrome; 11, 12, 17 // 12 — Firefox; 17 — Huawei ], "preset": "XXXXX-XXXXX", // optional. Push Preset Code from your Control Panel. // If specific params are sent in the request, // they override preset's params. "send_rate": 100, // optional. Throttling. Valid values are from 100 to 1000 pushes/second. "send_rate_avoid": true, // optional. If set to true, throttling limit will not be applied to // this specific push notification. // Templating related, please refer to the Template Engine guide to learn more "template_bindings": { // optional. "TemplatePlaceholder": "Value" }, "dynamic_content_placeholders": { // optional. Placeholders for dynamic content instead of device tags. "firstname": "John", "lastname": "Doe" },
// Frequency capping params. Ensure that Global frequency capping is configured in the Control Panel. "capping_days": 30, // optional. Amount of days for frequency capping (max 30 days) "capping_count": 10, // optional. The max number of pushes that can be sent from a // specific app to a particular device within a 'capping_days' // period. In case the message created exceeds the // 'capping_count' limit for a device, it won't // be sent to that device. "capping_exclude": true, // optional. If set to true, this push notification will not // be counted towards the capping for future pushes. "capping_avoid": true, // optional. If set to true, capping will not be applied to // this specific push notification.
// To save the message to the Inbox via API, use "inbox_date" or "inbox_image". // The message is saved when at least one of these parameters is used. "inbox_date": "2017-02-02", // optional. Specify when to remove a message from the Inbox. // Message will be removed from Inbox at 00:00:01 UTC // of the date specified, so the previous date is the // last day a user can see the message in their Inbox. // If not specified, the default removal date is the // next day after the send date. "inbox_image": "Inbox image URL", // optional. The image to be shown near the message. "inbox_days": 5, // optional. Specify when to remove a message from the // Inbox(lifetime of an inbox message in days). // Can be used instead of the "inbox_date" parameter. // Up to 30 days.
"devices": [ // optional. Specify tokens or hwids to send targeted push "hwid_XXXX" // notifications. Not more than 1000 tokens/hwids in ], // an array. If set, the message will only be sent to // the devices on the list. Application Group for devices // list is not allowed. iOS push tokens can only be lower case. "to": [ // optional. For email, SMS, and similar channels. List of recipients "email_1", "email_2" // (e.g. email addresses, phone numbers). Max 1000 items. ], // For push, use "devices" instead. // User-centric push notifications "users": [ // optional. If set, message will only be delivered to the "user_XXXX" // specified user ID's (set via /registerUser call). ], // If specified together with devices or to, // the latter will be ignored. Not more than 1000 user // ID's in an array. Application Group for users list // is not allowed.
// Filters and conditions "filter": "FILTER_NAME", // optional. "conditions": [ // optional. See the remark below. ["Country", "EQ", "fr"], ["Language", "EQ", "en"] ], "conditions_operator": "AND" // optional. Logical operator for conditions arrays. // Possible values: AND | OR. AND is default. }] }}ตัวอย่างคำขอการแจ้งเตือน VoIP
Anchor link toPushwoosh รองรับการแจ้งเตือนการโทรสไตล์ VoIP สำหรับ iOS และ Android
ด้านล่างนี้คุณจะพบตัวอย่างคำขอ API createMessage สำหรับแต่ละแพลตฟอร์ม
{ "request": { "application": "XXXXX-XXXXX", // required. Pushwoosh application code. "auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel. "notifications": [ { "voip_push": true, // required. Parameter is required to send out a VoIP push notification. "ios_root_params": { "aps": { "mutable-content": 1 // required for iOS10+ Media attachments. }, "callerName": "CallerName", // optional. Caller name. If not specified, "unknown caller" is shown. "video": true, // optional. Indicates whether video calls are supported. "supportsHolding": true, // optional. Indicates whether call holding functionality is supported. "supportsDTMF": false, // optional. Controls Dual-Tone Multi-Frequency signal support. "callId": "42", // optional. The unique identifier of the call to cancel. "cancelCall": true // optional. Set to "true" to cancel the call with the specified "callId". } } ] }}Android
Anchor link to{ "request": { "application": "XXXXX-XXXXX", // required. Pushwoosh application code. "auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel. "notifications": [ { "voip_push": true, // required. Parameter is required to send out a VoIP push notification. "android_root_params": { "callerName": "callerName", // optional. Caller name. If not specified, "unknown caller" is shown. "video": true, // optional. Indicates whether video calls are supported. "callId": 42, // optional. The unique identifier of the call to cancel. "cancelCall": true // optional. Set to "true" to cancel the call with the specified "callId". } } ] }}พารามิเตอร์เฉพาะแพลตฟอร์ม
Anchor link toพารามิเตอร์ iOS
Anchor link to{ "request": { "application": "12345-67891", // required. Pushwoosh application code "auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel "notifications": [{ "ios_title": { // optional. Object OR string. Adds iOS specific title for push notification. "en": "title" }, "ios_subtitle": { // optional. Object OR string. Adds iOS specific subtitle for push notification. "en": "subtitle" }, "ios_content": { // optional. Object OR string. Adds iOS specific content for push notification. "en": "content" }, "ios_badges": 5, // optional. iOS application badge number. // Use "+n" or "-n" to increment/decrement the badge value by n. "ios_sound": "sound file.wav", // optional. Sound file name in the main bundle of application. // If left empty, the device will produce a default system sound. "ios_sound_off": true, // optional. Enable/disable sound set by "ios_sound" field. "ios_ttl": 3600, // optional. Time to live parameter - maximum message lifespan in seconds. "ios_silent": 1, // optional. Enables silent notifications (ignore "sound" and "content"). "ios_category_id": "1", // optional. iOS8 category ID from Pushwoosh. "ios_root_params": { // optional. Root level parameters to the aps dictionary. "aps": { "content-available": "0", // optional. Set "1" to send a silent push and "0" for regular push. "mutable-content": 1 // required for iOS10+ Media attachments. }, "callerName": "CallerName", // optional VoIP parameter. Caller name. If not specified, "unknown caller" is shown. "video": true, // optional VoIP parameter. Indicates whether video calls are supported. "supportsHolding": true, // optional VoIP parameter. Indicates whether call holding functionality is supported. "supportsDTMF": false, // optional VoIP parameter. Controls Dual-Tone Multi-Frequency signal support. "data": {} // optional User supplied data, max of 4KB }, "ios_attachment": "URL", // optional. Insert media content in notification. "ios_thread_id": "some thread id", // optional. Identifier to group related notifications. // Messages with the same thread ID will be grouped // on the lock screen and in the Notification Center. "ios_critical": true, // optional. Marks iOS notification as a critical alert // playing sound even if a device is muted or // Do Not Disturb mode is on. "ios_category_custom": "category", // optional. Custom APNS category. "ios_interruption_level": "active", // optional. One of "passive", "active", "time-sensitive", // "critical". Indicates the importance and // delivery timing of a notification. Refer to the // One-time push guide for details. "apns_trim_content": 1 // optional. (0|1) Trims the exceeding content strings with ellipsis. }] }}พารามิเตอร์ Android
Anchor link to{ "request": { "application": "12345-67891", // required. Pushwoosh application code "auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel "notifications": [{ "android_header": { // optional. Android notification header. "en": "header" }, "android_content": { // optional. Android notification content. "en": "content" }, "android_root_params": { // optional. Custom key-value object. "key": "value", // Root level parameters for the android payload recipients. "CancelID": 12345678, // optional. Cancels the push notification with the "voip": true, // required VoIP parameter. Parameter is required to send out VoIP push notifications. "callerName": "callerName", // optional VoIP parameter. Caller name. If not specified, "unknown caller" is shown. "video": true, // optional VoIP parameter. Indicates whether video calls are supported. }, // specified Message ID (get the ID from the Message History) "android_sound": "soundfile", // optional. No file extension. If left empty, // the device will produce a default system sound. "android_sound_off": true, // optional. Enable/disable sound set by "android_sound" field "android_icon": "icon.png", // optional. "android_custom_icon": "URL.png", // optional. Full URL to the image file. "android_banner": "URL.png", // optional. Full URL to the image file. "android_badges": 5, // optional. Android application icon badge number. // Use "+n" or "-n" to increment/decrement the badge value by n. "android_gcm_ttl": 3600, // optional. Time to live parameter — maximum message lifespan in seconds. "android_vibration": 0, // optional. Android force-vibration for high-priority pushes. "android_led": "#rrggbb", // optional. LED hex color, device will do its best approximation. "android_priority": -1, // optional. Sets the "importance" parameter for devices with // Android 8.0 and higher, as well as the "priority" parameter // for devices with Android 7.1 and lower. Establishes the // interruption level of a notification channel or a particular // notification. Valid values are -2, -1, 0, 1, 2. "android_delivery_priority": "normal", // optional. "normal" or "high". // Enables notification’s delivery when the // device is in the power saving mode. "android_ibc": "#RRGGBB", // optional. icon background color on Lollipop, #RRGGBB, // #AARRGGBB, "red", "black", "yellow", etc. "android_silent": 1, // optional. 0 or 1. Enable silent notification. // Ignore sound and content "android_group_id": "123" // optional. Identifier to group related notifications. Messages with // the same thread ID will be grouped in // the Notification Center. }] }}พารามิเตอร์ Huawei
{ "request": { "application": "12345-67891", // required. Pushwoosh application code "auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel "notifications": [{ "huawei_android_header": { // optional. Object OR string. Notification title "en": "header" }, "huawei_android_content": { // optional. Object OR string. Notification content "en": "content" }, "huawei_android_badges": true, // optional. "huawei_android_silent": 0, // optional. 0 or 1. Enable silent notification. // Ignore sound and content "huawei_android_icon": "URL.png", // optional. "huawei_android_led": "#FF0011", // optional. LED hex color, device will do its best approximation "huawei_android_vibration": 1, // optional. Huawei force-vibration for high-priority pushes "huawei_android_sound": "sound.wav", // optional. If left empty, the device will produce // a default system sound "huawei_android_sound_off": true, // optional. Enable/disable sound set by // "huawei_android_sound" field "huawei_android_custom_icon": "URL.png", // optional "huawei_android_gcm_ttl": 2400, // optional. Time to live parameter - maximum // message lifespan in seconds "huawei_android_banner": "URL.png", // optional. Full path URL to the image file "huawei_android_root_params": { // optional. Custom key-value object. "key": "value" // Root-level parameters for Huawei payload recipients. }, "huawei_android_priority": 0, // optional. Valid values: -2, -1, 0, 1, 2 "huawei_android_ibc": "#0011AA", // optional. Icon background color on Lollipop "huawei_android_lockscreen": 1, // optional "huawei_android_delivery_priority": "normal", // optional. "normal" or "high". Enables notification // delivery in power saving mode "huawei_android_group_id": "group_id" // optional. Identifier to group related notifications }] }}พารามิเตอร์ Safari
Anchor link to{ "request": { "application": "12345-67891", // required. Pushwoosh application code "auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel "notifications": [{ "safari_url_args": [ // required, but the value may be empty "firstArgument", "secondArgument" ], "safari_title": { // optional. Object OR string. Title of the notification. "en": "content" }, "safari_content": { // optional. Object OR string. Content of the notification. "en": "content" }, "safari_action": "Click here", // optional. "safari_ttl": 3600 // optional. Time to live parameter — the maximum // lifespan of a message in seconds. }] }}พารามิเตอร์ Chrome
Anchor link to{ "request": { "application": "12345-67891", // required. Pushwoosh application code "auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel "notifications": [{ "chrome_title": { // optional. Object OR string. You can specify the header "en": "title" // of the message in this parameter. }, "chrome_content": { // optional. Object OR string. You can specify the content "en": "content" // of a message in this parameter. }, "chrome_icon": "URL.png", // optional. Full URL to the icon or extension resources file path "chrome_gcm_ttl": 3600, // optional. Time to live parameter – maximum message lifespan in seconds. "chrome_duration": 20, // optional. max 50 seconds. Changes chrome push display time. // Set to 0 to display push until user interacts with it. "chrome_image": "image_URL", // optional. URL to large image. "chrome_root_params": { // optional. Set parameters specific to messages sent to Chrome. "key": "value" }, "chrome_button_text1": "text1", // optional "chrome_button_url1": "button1_URL", // optional. Ignored if chrome_button_text1 is not set. "chrome_button_text2": "text2", // optional "chrome_button_url2": "button2_url" // optional. Ignored if chrome_button_text2 is not set. }] }}พารามิเตอร์ Firefox
Anchor link to{ "request": { "application": "12345-67891", // required. Pushwoosh application code "auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel "notifications": [{ "firefox_title": { // optional. Object OR string. You can specify message header here. "en": "title" }, "firefox_content": { // optional. Object OR string. You can specify message content here. "en": "content" }, "firefox_icon": "URL.png", // optional. Full path URL to the icon or path to the // file in extension resources. "firefox_root_params": { // optional. Set parameters specific to messages sent to Firefox. "key": "value" } }] }}พารามิเตอร์ Amazon
Anchor link to{ "request": { "application": "12345-67891", // required. Pushwoosh application code "auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel "notifications": [{ "adm_header": { // optional. Object OR string. You can specify message header here. "en": "header" }, "adm_content": { // optional. Object OR string. You can specify message content here. "en": "content" }, "adm_root_params": { // optional. Custom key-value object "key": "value" }, "adm_sound": "push.mp3", // optional. "adm_sound_off": true, // optional. Enable/disable sound set by "adm_sound" field "adm_icon": "icon.png", // optional. Full URL to the icon. "adm_custom_icon": "URL.png", // optional. "adm_banner": "URL.png", // optional. "adm_ttl": 3600, // optional. Time to live parameter — the maximum message // lifespan in seconds. "adm_priority": -1 // optional. Priority of the push in Amazon push drawer, // valid values are -2, -1, 0, 1 and 2. }] }}พารามิเตอร์ Mac OS X
Anchor link to{ "request": { "application": "12345-67891", // required. Pushwoosh application code "auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel "notifications": [{ "mac_title": { // optional. Object OR string. Adds Title for push notification. "en": "title" }, "mac_subtitle": { // optional. Adds subtitle for push notification. "en": "subtitle" }, "mac_content": { // optional. Adds content for push notification. "en": "content" }, "mac_badges": 3, // optional. "mac_sound": "sound.caf", // optional. "mac_sound_off": true, // optional. Enable/disable sound set by "mac_sound" field "mac_root_params": { // optional. "content-available": 1 }, "mac_ttl": 3600 // optional. Time to live parameter — maximum message lifespan in seconds. }] }}พารามิเตอร์ Windows
Anchor link to{ "request": { "application": "12345-67891", // required. Pushwoosh application code "auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel "notifications": [{ "wns_content": { // required. Content (XML or raw) of notification encoded in MIME's base64 // in form of Object OR String "en": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48YmFkZ2UgdmFsdWU9ImF2YWlsYWJsZSIvPg==", "de": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48YmFkZ2UgdmFsdWU9Im5ld01lc3NhZ2UiLz4=" }, "wns_type": "Badge", // optional. 'Tile' | 'Toast' | 'Badge' | 'Raw' "wns_tag": "myTag", // optional. Used in Tile replacement policy. // An alphanumeric string of no more than 16 characters. "wns_cache": 1, // optional. (1|0) Translates into X-WNS-Cache-Policy value. "wns_ttl": 600 // optional. Expiration time for notification in seconds. }] }}การตอบกลับ:
| รหัสสถานะ HTTP | status_code | คำอธิบาย |
|---|---|---|
| 200 | 200 | สร้างข้อความสำเร็จ |
| 200 | 210 | ข้อผิดพลาดของอาร์กิวเมนต์ ดูข้อมูลเพิ่มเติมใน status_message |
| 400 | N/A | สตริงคำขอมีรูปแบบไม่ถูกต้อง |
| 500 | 500 | ข้อผิดพลาดภายใน |
การติดตามข้อความ API
Anchor link toเพื่อวัตถุประสงค์ในการปรับสมดุลภาระงาน เราจะไม่จัดเก็บข้อความที่ส่งผ่าน API ด้วยพารามิเตอร์ “devices” ที่มีอุปกรณ์น้อยกว่า 10 เครื่องในอาร์เรย์ ด้วยเหตุนี้ ข้อความดังกล่าวจะไม่แสดงใน Message History ของคุณ
หากต้องการดูรายงาน push ในระหว่างขั้นตอนการทดสอบ ให้ใช้ การติดตามข้อความ API การเปิดตัวเลือกนี้ ON จะช่วยให้คุณ สามารถลบล้างขีดจำกัดนี้เป็นเวลา 1 ชั่วโมงและบันทึก push ดังกล่าวใน Message History การติดตามข้อความ API จะปิด OFF โดยอัตโนมัติหลังจาก 1 ชั่วโมง
การติดตามข้อความ API สามารถเปิดใช้งานได้ที่หน้า Message History โดยคลิก Start API messaging tracing ที่มุมขวาบน
เงื่อนไขแท็ก
Anchor link toเงื่อนไขแท็กแต่ละรายการเป็นอาร์เรย์ในรูปแบบ [tagName, operator, operand] โดยที่
- tagName: ชื่อของแท็ก
- operator: “EQ” | “IN” | “NOTEQ” | “NOTIN” | “LTE” | “GTE” | “BETWEEN” | “NOTSET” | “ANY”
- operand: string | integer | array | date
คำอธิบายตัวดำเนินการ
Anchor link to- EQ: ค่าแท็กเท่ากับ operand;
- IN: ค่าแท็กตัดกับ operand (operand ต้องเป็นอาร์เรย์เสมอ);
- NOTEQ: ค่าแท็กไม่เท่ากับ operand;
- NOTIN: ค่าแท็กไม่ตัดกับ operand (operand ต้องเป็นอาร์เรย์เสมอ);
- GTE: ค่าแท็กมากกว่าหรือเท่ากับ operand;
- LTE: ค่าแท็กน้อยกว่าหรือเท่ากับ operand;
- BETWEEN: ค่าแท็กมากกว่าหรือเท่ากับค่า operand ต่ำสุด แต่น้อยกว่าหรือเท่ากับค่า operand สูงสุด (operand ต้องเป็นอาร์เรย์เสมอ);
- NOTSET: ไม่ได้ตั้งค่าแท็ก ไม่พิจารณา Operand;
- ANY: แท็กมีค่าใดๆ ไม่พิจารณา Operand
แท็กสตริง
Anchor link toตัวดำเนินการที่ใช้ได้: EQ, IN, NOTEQ, NOTIN, NOTSET, ANY
Operands ที่ใช้ได้:
- EQ, NOTEQ: operand ต้องเป็นสตริง;
- IN, NOTIN: operand ต้องเป็นอาร์เรย์ของสตริง เช่น
["value 1", "value 2", "value N"]; - NOTSET: ไม่ได้ตั้งค่าแท็ก ไม่พิจารณา Operand;
- ANY: แท็กมีค่าใดๆ ไม่พิจารณา Operand
แท็กจำนวนเต็ม
Anchor link toตัวดำเนินการที่ใช้ได้: EQ, IN, NOTEQ, NOTIN, BETWEEN, GTE, LTE, NOTSET, ANY
Operands ที่ใช้ได้:
- EQ, NOTEQ, GTE, LTE: operand ต้องเป็นจำนวนเต็ม;
- IN, NOTIN: operand ต้องเป็นอาร์เรย์ของจำนวนเต็ม เช่น
[value 1, value 2, value N]; - BETWEEN: operand ต้องเป็นอาร์เรย์ของจำนวนเต็ม เช่น
[min_value, max_value]; - NOTSET: ไม่ได้ตั้งค่าแท็ก ไม่พิจารณา Operand;
- ANY: แท็กมีค่าใดๆ ไม่พิจารณา Operand
แท็กวันที่
Anchor link toตัวดำเนินการที่ใช้ได้: EQ, IN, NOTEQ, NOTIN, BETWEEN, GTE, LTE, NOTSET, ANY
Operands ที่ใช้ได้:
"YYYY-MM-DD 00:00"(สตริง)- unix timestamp
1234567890(จำนวนเต็ม) "N days ago"(สตริง) สำหรับตัวดำเนินการ EQ, BETWEEN, GTE, LTE
แท็กบูลีน
Anchor link toตัวดำเนินการที่ใช้ได้: EQ, NOTSET, ANY
Operands ที่ใช้ได้: 0, 1, true, false
แท็กรายการ
Anchor link toตัวดำเนินการที่ใช้ได้: IN, NOTIN, NOTSET, ANY
Operands ที่ใช้ได้: operand ต้องเป็นอาร์เรย์ของสตริง เช่น ["value 1", "value 2", "value N"]
/createMessage snippets
Anchor link toตัวอย่างคำขอ /createMessage:
#!/bin/bash
#Usageif [ ! -n "$1" ] || [ ! -n "$2" ]then echo "`basename $0` usage: api_token appid message"; exit 1;fi;MESSAGE="$3";if [ -z "$3" ]thenMESSAGE='One push to rule them all!'fi;
echo -e "Response:"curl --data-binary "{\"request\": {\"application\":\"$2\", \"auth\":\"$1\", \"notifications\": [{ \"send_date\": \"now\", \"content\": \"$MESSAGE\" }] }}" \-H "Content-type: application/json" \"https://api.pushwoosh.com/json/1.3/createMessage"echo "";exit 0;<?phpdefine('PW_AUTH', 'API TOKEN');define('PW_APPLICATION', 'APPLICATION CODE');define('PW_DEBUG', true);
function pwCall($method, $data) { $url = 'https://api.pushwoosh.com/json/1.3/' . $method; $request = json_encode(['request' => $data]);
$ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate'); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
$response = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch);
if (defined('PW_DEBUG') && PW_DEBUG) { print "[PW] request: $request"; print "[PW] response: $response"; print '[PW] info: ' . print_r($info, true); }}
pwCall('createMessage', array( 'application' => PW_APPLICATION, 'auth' => PW_AUTH, 'notifications' => array( array( 'send_date' => 'now', 'content' => 'test', 'data' => array('custom' => 'json data'), 'link' => 'https://pushwoosh.com/' ) ) ));-module(pushwoosh).-export([run/0, stop/0, sendMessage/1]).%% sendMessage argument: message text %%
%% Authentication & App_id %%-define(PW_AUTH, "YOUR_AUTH_TOKEN").-define(PW_APPLICATION, "YOUR_PUSHWOOSH_APP_CODE").
%% KickStart %%run() -> application:start(unicode), application:start(crypto), application:start(public_key), application:start(ssl), application:start(inets), %% HTTP Client verbosity options flase, verbose, debug httpc:set_options([{verbose, false}]).stop() -> application:stop(ssl), application:stop(public_key), application:stop(crypto), application:stop(inets).%% JSON Wars !encode(S) -> encode(S, [$"]).encode([], Acc) -> lists:reverse([$" | Acc]);encode([C | Cs], Acc) -> Hex = lists:flatten(io_lib:format("~4.16.0b", [C])), encode(Cs, lists:reverse(Hex) ++ "u\" ++ Acc).
sendMessage(Message_text) -> %% URL to JSON API 1.3 Url = "https://api.pushwoosh.com/json/1.3/createMessage", EncodedMessage = encode(Message_text), {ok, Response} = httpc:request( %%Method post, %%Request {Url, [{"User-Agent", "Erlang exemple"}], "application/json; charset=UTF-8", "{\"request\":{ \"application\": \""?PW_APPLICATION"\", \"auth\": \""?PW_AUTH"\", \"notifications\": [{ \"send_date\": \"now\", \"content\": "++EncodedMessage++" }]}}"}, %%HTTP options [{ssl,[{verify, verify_none}]}, {version, "HTTP/1.0"}], %%Options []), io:format("And received ~p", [Response]).class PushNotification
#- PushWoosh API Documentation https://www.pushwoosh.com/programming-push-notification/pushwoosh-push-notification-remote-api/ #- Two methods here: # - PushNotification.new.notify_all(message) Notifies all with the same option # - PushNotification.new.notify_devices(notification_options = {}) Notifies specific devices with custom options
include HTTParty #Make sure to have the HTTParty gem declared in your gemfile https://github.com/jnunemaker/httparty default_params :output => 'json' format :json
def initialize #- Change to your settings @auth = {:application => "00000-00000",:auth => "auth_token"} end
# PushNotification.new.notify_all("This is a test notification to all devices") def notify_all(message) notify_devices({:content => message}) end
# PushNotification.new.notify_device({ # :content => "TEST", # :data => {:custom_data => value}, # :devices => array_of_tokens #}) def notify_devices(notification_options = {}) #- Default options, uncomment :data or :devices if needed default_notification_options = { # YYYY-MM-DD HH:mm OR 'now' :send_date => "now", # Object( language1: 'content1', language2: 'content2' ) OR string :content => { :fr => "Test", :en => "Test" }, # JSON string or JSON object "custom": "json data" #:data => { # :custom_data => value #}, # omit this field (push notification will be delivered to all the devices for the application), or provide the list of devices IDs #:devices => {} }
#- Merging with specific options final_notification_options = default_notification_options.merge(notification_options)
#- Constructing the final call options = @auth.merge({:notifications => [final_notification_options]}) options = {:request => options} #- Executing the POST API Call with HTTPARTY - :body => options.to_json allows us to send the json as an object instead of a string response = self.class.post("https://api.pushwoosh.com/json/1.3/createMessage", :body => options.to_json,:headers => { 'Content-Type' => 'application/json' }) endend// Uses JSON classes from https://json.org/java/
package com.arellomobile;
import org.json.*;import java.io.*;import java.net.*;
public class SendPushNotificationSample{ public static final String PUSHWOOSH_SERVICE_BASE_URL = "https://api.pushwoosh.com/json/1.3/"; private static final String AUTH_TOKEN = "YOUR_AUTH_TOKEN"; private static final String APPLICATION_CODE = "PW_APPLICATION_CODE";
public static void main(String[] args) throws JSONException, MalformedURLException { String method = "createMessage"; URL url = new URL(PUSHWOOSH_SERVICE_BASE_URL + method);
JSONArray notificationsArray = new JSONArray() .put(new JSONObject().put("send_date", "now") .put("content", "test") .put("link", "https://pushwoosh.com/"));
JSONObject requestObject = new JSONObject() .put("application", APPLICATION_CODE) .put("auth", AUTH_TOKEN) .put("notifications", notificationsArray);
JSONObject mainRequest = new JSONObject().put("request", requestObject); JSONObject response = SendServerRequest.sendJSONRequest(url, mainRequest.toString());
System.out.println("Response is: " + response); }}
class SendServerRequest{ static JSONObject sendJSONRequest(URL url, String request) { HttpURLConnection connection = null; try { connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("POST"); connection.setRequestProperty("Content-Type", "application/json"); connection.setDoInput(true); connection.setDoOutput(true);
DataOutputStream writer = new DataOutputStream(connection.getOutputStream()); writer.write(request.getBytes("UTF-8")); writer.flush(); writer.close();
return parseResponse(connection); } catch (Exception e) { System.out.println("An error occurred: " + e.getMessage()); return null; } finally { if (connection != null) { connection.disconnect(); } } }
static JSONObject parseResponse(HttpURLConnection connection) throws IOException, JSONException { String line; BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); StringBuilder response = new StringBuilder();
while ((line = reader.readLine()) != null) { response.append(line).append(''); } reader.close();
return new JSONObject(response.toString()); }}import json
PW_AUTH = 'API TOKEN'PW_APPLICATION_CODE = 'APPLICATION CODE'
try: # For Python 3.0 and later from urllib.request import urlopen from urllib.request import Requestexcept ImportError: # Fall back to Python 2's urllib2 from urllib2 import urlopen from urllib2 import Request
def pw_call(method, data): url = 'https://api.pushwoosh.com/json/1.3/' + method data = json.dumps({'request': data}) req = Request(url, data.encode('UTF-8'), {'Content-Type': 'application/json'}) try: f = urlopen(req) response = f.read() f.close() print('Pushwoosh response: ' + str(response)) except Exception as e: print ('Request error: ' + str(e))
if __name__ == '__main__': pw_call('createMessage', { 'auth': PW_AUTH, 'application': PW_APPLICATION_CODE, 'notifications': [ { 'send_date': 'now', 'content': 'test', 'data': {"custom": "json data"}, 'link': 'https://pushwoosh.com' } ] } )using System;using System.IO;using System.Net;using Newtonsoft.Json.Linq;
namespace WebApplication1{ public partial class Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string pwAuth = "YOUR_AUTH_TOKEN"; string pwApplication = "PW_APPLICATION_CODE"; JObject json = new JObject( new JProperty("application", pwApplication), new JProperty("auth", pwAuth), new JProperty("notifications", new JArray( new JObject( new JProperty("send_date", "now"), new JProperty("content", "test"), new JProperty("wp_type", "Toast"), new JProperty("wp_count", 3), new JProperty("data", new JObject( new JProperty("custom", "json data"))), new JProperty("link", "https://pushwoosh.com/"), new JProperty("conditions", new JArray( (object)new JArray("Color", "EQ", "black"))))))); PWCall("createMessage", json); } private void PWCall(string action, JObject data) { Uri url = new Uri("https://api.pushwoosh.com/json/1.3/" + action); JObject json = new JObject(new JProperty("request", data)); DoPostRequest(url, json); } private void DoPostRequest(Uri url, JObject data) { HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url); req.ContentType = "text/json"; req.Method = "POST"; using (var streamWriter = new StreamWriter(req.GetRequestStream())) { streamWriter.Write(data.ToString()); } HttpWebResponse httpResponse; try { httpResponse = (HttpWebResponse)req.GetResponse(); } catch (Exception exc) { throw new Exception(string.Format("Problem with {0}, {1}", url, exc.Message)); } using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { var responseText = streamReader.ReadToEnd(); Page.Response.Write(responseText); } } }}package main
import( "fmt" "encoding/json" "net/http" "bytes" "io/ioutil")
const ( PW_APPLICATION = "APPLICATION CODE" PW_AUTH = "API TOKEN" PW_ENDPOINT = "https://api.pushwoosh.com/json/1.3/")
func pwCall(method string, data []byte) (bool) { url := PW_ENDPOINT + method request, err := http.NewRequest("POST", url, bytes.NewBuffer(data)) request.Header.Set("Content-Type", "application/json")
client := http.Client{} response, err := client.Do(request) if err != nil { fmt.Println("Error occur: " + err.Error()) return false } defer response.Body.Close()
fmt.Println("Response Status: ", response.Status) if (response.StatusCode == 200) { body, _ := ioutil.ReadAll(response.Body) fmt.Println("Response Body: ", string(body)) return true } return false}
func main() { requestData := map[string]interface{}{ "request": map[string]interface{} { "auth": PW_AUTH, "application": PW_APPLICATION, "notifications": []interface{}{ map[string]interface{} { "send_date": "now", "content": "test", "link": "https://pushwoosh.com", }, }, }, } jsonRequest, _ := json.Marshal(requestData) requestString := string(jsonRequest) fmt.Println("Request body: " + requestString)
pwCall("createMessage", jsonRequest)}$.ajax({ type: "POST", url: "https://api.pushwoosh.com/json/1.3/createMessage", data: JSON.stringify({ "request": { "application": "APPLICATION CODE", "auth": "API TOKEN", "notifications": [{ "send_date": "now", "ignore_user_timezone": true, "content": "Hello world!" }] } }), dataType: "json"}).done(function(data) { console.log(data);});deleteMessage
Anchor link toPOST https://api.pushwoosh.com/json/1.3/deleteMessage
ลบข้อความที่ตั้งเวลาไว้
Request Body
Anchor link to| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
| auth* | string | API access token จาก Pushwoosh Control Panel |
| message* | string | Message code ที่ได้รับจากคำขอ /createMessage |
{ "status_code": 200, "status_message": "OK"}{ "request":{ "auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel "message": "xxxx-xxxxxxx-xxxxxx" // required. Message code obtained in /createMessage }}รหัสสถานะ:
| รหัสสถานะ HTTP | status_code | คำอธิบาย |
|---|---|---|
| 200 | 200 | ลบข้อความสำเร็จ |
| 200 | 210 | ข้อผิดพลาดของอาร์กิวเมนต์ ดูข้อมูลเพิ่มเติมใน status_message |
| 400 | N/A | สตริงคำขอมีรูปแบบไม่ถูกต้อง |
| 500 | 500 | ข้อผิดพลาดภายใน |
<?php// see https://gomoob.github.io/php-pushwoosh/delete-message.htmluse Gomoob\Pushwoosh\Model\Request\DeleteMessageRequest;
// creates request instance$request = DeleteMessageRequest::create()->setMessage('MESSAGE_CODE');
// call '/deleteMessage' Web Service$response = $pushwoosh->deleteMessage($request);
if($response->isOk()) { print 'Great, my message has been deleted !';} else { print 'Oups, the deletion failed :-('; print 'Status code : ' . $response->getStatusCode(); print 'Status message : ' . $response->getStatusMessage();}getMessageDetails
Anchor link toPOST https://api.pushwoosh.com/json/1.3/getMessageDetails
ดึงรายละเอียดข้อความ
Request Body
Anchor link to| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
| auth* | string | API access token จาก Pushwoosh Control Panel |
| message* | string | Message code หรือ ID ข้อความ |
{ "status_code": 200, "status_message": "OK", "response": { "message": { "id": 2068991743, "created": "2016-09-14 17:19:42", "send_date": "2016-09-14 17:19:41", "status": "done", "content": { "en": "Hello {Name|CapitalizeFirst|friend}! 🚀" }, "platforms": "[1]", "ignore_user_timezone": "1", "code": "XXXX-92B4C3C5-A7F5EF70", "data": { "key": "value" } } }}{ "request":{ "auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel "message": "xxxx-xxxxxxx-xxxxxx" // required. message code or message ID }}createTargetedMessage
Anchor link toPOST https://api.pushwoosh.com/json/1.3/createTargetedMessage
สร้าง push notification แบบกำหนดเป้าหมายใหม่
Request Body
Anchor link to| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
| auth* | string | API access token จาก Pushwoosh Control Panel |
| devices_filter* | string | ดูหมายเหตุด้านล่าง |
| send_date* | string | YYYY-MM-DD HH:mm หรือ ‘now’ |
| ignore_user_timezone | boolean | หากละเว้น จะใช้ UTC-0 เป็นค่าเริ่มต้นสำหรับ “send_date” |
| timezone | string | หากละเว้น จะใช้ UTC-0 เป็นค่าเริ่มต้นสำหรับ “send_date” |
| campaign | string | รหัสของแคมเปญ ที่คุณต้องการกำหนดข้อความ push นี้ |
| content* | string | เนื้อหาการแจ้งเตือน ดูรายละเอียดในตัวอย่างคำขอ |
| transactionId | string | ตัวระบุข้อความที่ไม่ซ้ำกันเพื่อป้องกันข้อความซ้ำซ้อนในกรณีที่เกิดปัญหาเครือข่าย จัดเก็บไว้ที่ฝั่ง Pushwoosh เป็นเวลา 5 นาที |
| link | string | ลิงก์ที่จะเปิดเมื่อผู้ใช้เปิดข้อความ push |
| minimize_link | integer | 0 - ไม่ย่อ, 2 - bit.ly ค่าเริ่มต้น = 2 |
| data | object | สตริง JSON หรือออบเจ็กต์ JSON จะถูกส่งเป็นพารามิเตอร์ “u” ใน payload (แปลงเป็นสตริง JSON) |
| preset | string | รหัส Preset |
| send_rate | integer | การควบคุมปริมาณ ค่าที่ถูกต้องคือตั้งแต่ 100 ถึง 1000 push ต่อวินาที |
| inbox_date | string | ระบุเวลาที่จะลบข้อความออกจาก Inbox |
| inbox_image | string | URL ของรูปภาพที่จะแสดงใกล้กับข้อความใน Inbox |
{ "status_code": 200, "status_message": "OK", "response": { "messageCode": "97B0-C7473871-2FBDFDC6" }}The request cannot be fulfilled due to bad syntax.ตัวอย่างการตอบกลับเพิ่มเติม:
{ "status_code": 210, "status_message": "Errors occurred while compiling filter", "response": { "errors": [{ "message": "Invalid tag set specification. \")\" expected.", "type": "syntax" }] }}{ "status_code": 210, "status_message": "Errors occurred while compiling filter", "response": { "errors": [{ "message": "Application \"11111-11111\" not found", "type": "semantic", "near": "\"11111-11111\"" }] }}{ "status_code": 210, "status_message": "Errors occurred while compiling filter", "response": { "errors": [{ "message": "Invalid character \"/\" at 1:19", "type": "lexical" }] }}{ "request": { "auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel "devices_filter": "A(\"XXXXX-XXXXX\") * T(\"City\", EQ, \"Name\")", // required. Syntax explained below "send_date": "now", // optional. YYYY-MM-DD HH:mm OR 'now' "ignore_user_timezone": true, // optional. "timezone": "America/New_York", // optional. If ignored UTC-0 is default for "send_date". // More info https://php.net/manual/timezones.php. "campaign": "CAMPAIGN_CODE", // optional. Campaign code to which you want to assign this push message. "content": { // optional. Object OR string. Use "wns_content" instead for Windows. "en": "English", "de": "Deutsch" }, "transactionId": "unique UUID", // optional. Unique message identifier to prevent duplicating messages // in case of network problems. Stored on the side of // Pushwoosh for 5 minutes. "rich_media": "XXXXX-XXXXX", // optional. Copy the Rich Media code from the URL bar of the // Rich Media editor page in Pushwoosh Control Panel. "link": "https://google.com", // optional. For deeplinks add "minimize_link": 0 "minimize_link": 0, // optional. 0 — do not minimize, 2 — bitly. Default = 2. // Google URL shortener is disabled since March 30, 2019. // Please note that shorteners have restrictions // on a number of calls. "data": { // optional. JSON string or JSON object. "key": "value" // Will be passed as "u" parameter in the payload }, // (converted to JSON string). "preset": "XXXXX-XXXXX", // optional. Push Preset Code from your Control Panel. "send_rate": 100, // optional. Throttling. Valid values are from 100 to 1000 pushes/second. "dynamic_content_placeholders": { // optional. Placeholders for dynamic content instead of device tags. "firstname": "John", "lastname": "Doe" },
// To save the message to the Inbox via API, use "inbox_date" or "inbox_image". // The message is saved when at least one of these parameters is used. "inbox_image": "Inbox image URL", // optional. The image to be shown near the message. "inbox_date": "2017-02-02" // optional. Specify when to remove a message from the Inbox. // Message will be removed from Inbox at 00:00:01 UTC of // the date specified, so the previous date is the last // day a user can see the message in their Inbox. // If not specified, the default removal date is the next // day after the send date. }}{ "request": { "auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel "devices_filter": "FILTER CONDITION", "send_date": "now", // optional. YYYY-MM-DD HH:mm OR 'now' "content": { // optional. Object OR string. "en": "English", // Use "wns_content" instead for Windows. "de": "Deutsch" }, "ignore_user_timezone": true, // optional. "timezone": "America/New_York", // optional. If ignored UTC-0 is default for "send_date". // More info https://php.net/manual/timezones.php. "campaign": "CAMPAIGN_CODE", // optional. Campaign code to which you want to assign this push message.
// iOS related parameters "ios_badges": 5, // optional. iOS application badge number. // Use "+n" or "-n" to increment/decrement the badge value by n. "ios_sound": "sound file.wav", // optional. Sound file name in the main bundle of application. // If left empty, the device will produce no sound // upon receiving a push. "ios_sound_off": true, // optional. Enable/disable sound set by "ios_sound" field. "ios_ttl": 3600, // optional. Time to live parameter — maximum message lifespan in seconds. "ios_silent": 1, // optional. Enables silent notifications (ignore "sound" and "content"). "ios_category_id": "1", // optional. iOS8 category ID from Pushwoosh. "ios_category_custom": "category", // optional. Custom APNS category. "ios_root_params": { // optional. Root level parameters to the aps dictionary. "aps": { "content-available": "0", // optional. Set "1" to send a silent push and "0" for regular push. "mutable-content": 1 // required for iOS10+ Media attachments. }, "attachment": "YOUR_ATTACHMENT_URL", // iOS10+ media attachment URL. "data": {} // optional. User supplied data, max of 4KB }, "apns_trim_content": 1, // optional. (0|1) Trims the exceeding content strings with ellipsis. "ios_title": { // optional. Adds title for iOS push notification. "en": "title" }, "ios_subtitle": { // optional. Adds subtitle for iOS push notification. "en": "subTitle" }, "ios_content": { // optional. Adds content for iOS push notification. "en": "content" },
// Android related parameters "android_root_params": { // optional. Custom key-value object. "key": "value" // Root level parameters for the android payload recipients. }, "android_sound": "soundfile", // optional. No file extension. If left empty, the device // will produce no sound upon receiving a push. "android_sound_off": true, // optional. Enable/disable sound set by "android_sound" field "android_header": { // optional. Object OR string. Android notification header. "en": "header" }, "android_content": { // optional. Object OR string. Android notification content. "en": "content" }, "android_icon": "icon.png", "android_custom_icon": "URL.png", // optional. Full path URL to the image file. "android_banner": "URL.png", // optional. Full path URL to the image file. "android_badges": 5, // optional. integer. Android application icon badge number. // Use "+n" or "-n" to increment/decrement the badge value by n. "android_gcm_ttl": 3600, // optional. Time to live parameter — maximum message lifespan in seconds. "android_vibration": 0, // optional. Android force-vibration for high-priority pushes. "android_led": "#rrggbb", // optional. LED hex color, device will do its best approximation. "android_priority": -1, // optional. Sets the "importance" parameter for devices with Android 8.0 // and higher, as well as the "priority" parameter for devices // with Android 7.1 and lower. Establishes the interruption // level of a notification channel or a particular notification. // Valid values are -2, -1, 0, 1, 2. "android_delivery_priority": "normal", // optional. "normal" or "high". Enables notification’s delivery // when the device is in the power saving mode. "android_ibc": "#RRGGBB", // optional. icon background color on Lollipop, #RRGGBB, // #AARRGGBB, "red", "black", "yellow", etc. "android_silent": 1, // optional. 0 or 1. Enable silent notificaiton. // Ignore sound and content
// Amazon related parameters "adm_root_params": { // optional. Custom key-value object "key": "value" }, "adm_sound": "push.mp3", "adm_sound_off": true, // optional. Enable/disable sound set by "adm_sound" field "adm_header": { "en": "Header" }, "adm_content": { "en": "content" }, "adm_icon": "icon.png", "adm_custom_icon": "URL.png", "adm_banner": "URL.png", "adm_ttl": 3600, // optional. Time to live parameter — the maximum message // lifespan in seconds. "adm_priority": -1, // optional. Priority of the push in Amazon push drawer, // valid values are -2, -1, 0, 1 and 2.
// Mac OS X related parameters "mac_badges": 3, "mac_sound": "sound.caf", "mac_sound_off": true, "mac_root_params": { "content-available": 1 }, "mac_ttl": 3600, // optional. Time to live parameter — maximum message lifespan in seconds. "mac_title": { // optional. Adds Title for push notification. "en": "title" }, "mac_subtitle": { // optional. Adds subtitle for MacOS push notification. "en": "subtitle" }, "mac_content": { // optional. Adds content for MacOS push notification. "en": "content" },
// Windows related parameters "wns_content": { // required. Content (XML or raw) of notification encoded // in MIME's base64 in form of Object OR String "en": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48YmFkZ2UgdmFsdWU9ImF2YWlsYWJsZSIvPg==", "de": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48YmFkZ2UgdmFsdWU9Im5ld01lc3NhZ2UiLz4=" }, "wns_type": "Badge", // 'Tile' | 'Toast' | 'Badge' | 'Raw' "wns_tag": "myTag", // optional. Used in Tile replacement policy. // An alphanumeric string of no more than 16 characters. "wns_cache": 1, // optional. (1|0) Translates into X-WNS-Cache-Policy value. "wns_ttl": 600, // optional. Expiration time for notification in seconds.
// Safari related parameters "safari_title": { // optional. Object OR string. Title of the notification. "en": "title" }, "safari_content": { // optional. Object OR string. Content of the notification. "en": "content" }, "safari_action": "Click here", // optional. "safari_url_args": [ // required. but the value may be empty "firstArgument", "secondArgument" ], "safari_ttl": 3600, // optional. Time to live parameter — the maximum // lifespan of a message in seconds.
// Chrome related parameters "chrome_title": { // optional. You can specify the header of the message in this parameter. "en": "title" }, "chrome_content": { // optional. You can specify the content of the message in this parameter. "en": "content" }, "chrome_icon": "icon_URL", // optional. Full path URL to the icon or extension resources file path "chrome_gcm_ttl": 3600, // optional. Time to live parameter – maximum message lifespan in seconds. "chrome_duration": 20, // optional. Changes chrome push display time. Set to 0 to display push // until user interacts with it. "chrome_image": "image_URL", // optional. URL to large image "chrome_root_params": { // optional. Set parameters specific to messages sent to Chrome. "key": "value" }, "chrome_button_text1": "text1", // optional. "chrome_button_url1": "button1_URL", // optional. Ignored if chrome_button_text1 is not set. "chrome_button_text2": "text2", // optional. "chrome_button_url2": "button2_url", // optional. Ignored if chrome_button_text2 is not set.
// Firefox related parameters "firefox_title": { // optional. Object OR string. You can specify message header here. "en": "title" }, "firefox_content": { // optional. Object OR string. You can specify message content here. "en": "content" }, "firefox_icon": "icon_URL", // optional. Full path URL to the icon or path // to the file in extension resources. "firefox_root_params": { // optional. Set parameters specific to messages sent to Firefox. "key": "value" } }}พื้นฐานนั้นง่ายมาก – ตัวกรองทั้งหมดจะทำงานบน ชุด ของเอนทิตี
ชุดถูกกำหนดเป็น:
1. อุปกรณ์ที่สมัครรับข้อมูลจากแอปเฉพาะ (A);
2. อุปกรณ์ที่ตรงกับค่าแท็กที่ระบุ (T) หรือค่าแท็กเฉพาะแอป (AT);\
ไวยากรณ์
Anchor link toลองดูตัวอย่างบางส่วนตามรายการด้านบน
การกำหนดเป้าหมายผู้สมัครรับข้อมูลแอป
Anchor link toตัวกรอง “A” กำหนดชุดของอุปกรณ์ที่สมัครรับข้อมูลจากแอปเฉพาะ:
A("XXXXX-XXXXX", ["iOS", "Android", "OsX", "Windows", "Amazon", "Safari", "Chrome", "Firefox"])
โดยที่
- “XXXXX-XXXXX” – Pushwoosh Application Code
- [“iOS”, “Android”, …] – อาร์เรย์ของแพลตฟอร์มเป้าหมาย หากละเว้น ข้อความจะถูกส่งไปยังทุกแพลตฟอร์มที่มีให้สำหรับแอปนี้
การกรองตามค่าแท็ก
Anchor link toตัวกรอง “T” กำหนดชุดของอุปกรณ์ที่มีค่าแท็กที่ระบุไว้
T(\"Age\", IN, [17,20])
กำหนดชุดของอุปกรณ์ที่มีแท็ก “age” ตั้งค่าเป็นหนึ่งในค่า: 17, 18, 19, 20
ประเภทแท็กและตัวดำเนินการ
Anchor link toสิ่งที่สำคัญมากที่ต้องเข้าใจคือแท็กจะถูกแชร์ระหว่างแอป และเป็นเครื่องมือที่ทรงพลังมากสำหรับการแบ่งกลุ่มและกรองผู้ใช้เป้าหมายของคุณโดยไม่ต้องผูกมัดกับแอปใดแอปหนึ่ง
แท็กอาจเป็นหนึ่งในสามประเภทที่แตกต่างกัน: String, Integer, List ประเภทของแท็กจะกำหนดว่าคุณสามารถใช้ตัวดำเนินการใดกับแท็กนั้นๆ ได้
แท็กสตริง
Anchor link toตัวดำเนินการที่ใช้ได้:
- EQ – กำหนดเป้าหมายอุปกรณ์ที่มีค่าแท็กที่ระบุ
- IN – กำหนดเป้าหมายอุปกรณ์ที่มีค่าแท็กใดๆ ที่ระบุ
- NOTIN – กำหนดเป้าหมายอุปกรณ์ที่ไม่มีค่าแท็กที่ระบุ
- NOTEQ – กำหนดเป้าหมายอุปกรณ์ที่มีค่าแท็กไม่เท่ากับค่าที่ระบุ
- NOTSET – กำหนดเป้าหมายอุปกรณ์ที่ไม่มีค่าสำหรับแท็กที่ระบุ
- ANY – กำหนดเป้าหมายอุปกรณ์ที่มีค่าใดๆ ที่ตั้งไว้สำหรับแท็กที่ระบุ
ตัวอย่าง:
T (\"Age\", EQ, 30) – กรองผู้ใช้ที่มีอายุ 30 ปี
T (\"favorite_color\", IN, [\"red\",\"green\",\"blue\"]) – กรองผู้ใช้ที่เลือกสีแดง เขียว หรือน้ำเงินเป็นสีโปรด
T (\"Name", NOTSET, \"\") – กำหนดเป้าหมายอุปกรณ์ที่ไม่มีค่าสำหรับแท็ก Name
คุณสามารถใช้ค่าตัวเลขกับแท็กสตริงได้ แต่ค่าดังกล่าวจะถูกแปลงเป็นสตริง
แท็กจำนวนเต็ม
Anchor link toตัวดำเนินการที่ใช้ได้:
- GTE – มากกว่าหรือเท่ากับค่าที่ระบุ
- LTE– น้อยกว่าหรือเท่ากับค่าที่ระบุ
- EQ – เท่ากับค่าที่ระบุ
- BETWEEN – ระหว่างค่าต่ำสุดและสูงสุดที่ระบุ
- IN – ค่าใดๆ ที่ระบุ
- NOTIN – ไม่มีค่าที่ระบุที่กำหนดให้กับอุปกรณ์
- NOTEQ – อุปกรณ์ที่มีค่าแท็กไม่เท่ากับค่าที่ระบุ
- NOTSET – อุปกรณ์ที่ไม่มีค่าสำหรับแท็กที่ระบุ
- ANY – อุปกรณ์ที่มีค่าใดๆ ที่ตั้งไว้สำหรับแท็กที่ระบุ
ตัวอย่าง:
T (\"Level\", EQ, 14) – กรองผู้ใช้ที่อยู่ในระดับ 14 เท่านั้น
T (\"Level\", BETWEEN, [1,5) – กรองผู้ใช้ที่อยู่ในระดับ 1, 2, 3, 4 และ 5
T (\"Level", GTE, 29) – กำหนดเป้าหมายผู้ใช้ที่ไปถึงระดับ 29 เป็นอย่างน้อย
แท็กรายการ
Anchor link toตัวดำเนินการที่ใช้ได้:
- IN – อุปกรณ์ที่มีค่าแท็กใดๆ ที่ระบุ
ตัวอย่าง: T("Category", IN, ["breaking_news","business","politics"])
แท็กวันที่
Anchor link toตัวดำเนินการที่ใช้ได้:
- GTE – มากกว่าหรือเท่ากับค่าที่ระบุ
- LTE– น้อยกว่าหรือเท่ากับค่าที่ระบุ
- EQ – เท่ากับค่าที่ระบุ
- BETWEEN – ระหว่างค่าต่ำสุดและสูงสุดที่ระบุ
- NOTEQ – อุปกรณ์ที่มีค่าแท็กไม่เท่ากับค่าที่ระบุ
- NOTSET – อุปกรณ์ที่ไม่มีค่าสำหรับแท็กที่ระบุ
- ANY – อุปกรณ์ที่มีค่าใดๆ ที่ตั้งไว้สำหรับแท็กที่ระบุ
ตัวอย่าง:
AT("7777D-322A7","Last Application Open", BETWEEN, ["2022-02-28", "2022-03-02"])
AT("7777D-322A7","Last Application Open", GTE, "90 days ago")
การดำเนินการ
Anchor link to- “+” – รวมสองชุด (เท่ากับ OR)
- “*” – ตัดกันสองชุด (เท่ากับ AND)
- “\” – ลบชุดหนึ่งออกจากอีกชุดหนึ่ง (เท่ากับ NOT)
การดำเนินการทั้งหมดเป็นแบบเชื่อมโยงจากซ้ายไปขวา ”+” และ ”*” มีลำดับความสำคัญเท่ากัน "" มีลำดับความสำคัญสูงกว่า คุณสามารถใช้วงเล็บเพื่อกำหนดลำดับความสำคัญของการคำนวณได้
โปรดทราบว่าการดำเนินการ "" ไม่สามารถสลับที่ได้ A("12345-12345") \ A("67890-67890") ไม่เหมือนกับ A("67890-67890") \ A("12345-12345")
getPushHistory
Anchor link toPOST https://api.pushwoosh.com/json/1.3/getPushHistory
รับประวัติข้อความพร้อมรายละเอียด push
Request Body
Anchor link to| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
| auth* | string | API access token จาก Pushwoosh Control Panel |
| limitMessages | integer | จำกัดจำนวนข้อความในการตอบกลับ ค่าที่เป็นไปได้ตั้งแต่ 10 ถึง 1000 |
| source | string | แหล่งที่มาของประวัติ push อาจเป็น null หรือ: “CP”, “API”, “GeoZone”, “RSS”, “AutoPush”, “A/B Test” |
| searchBy | string | ค่าที่เป็นไปได้ในการค้นหา อาจเป็น null หรือ: “notificationID”, “notificationCode”, “applicationCode”, “campaignCode” |
| value | string | ค่าค้นหาที่ตั้งค่าตามฟิลด์ “searchBy” |
| lastNotificationID | string | ใช้สำหรับการแบ่งหน้า messageId สุดท้ายจากการเรียก /getPushHistory ก่อนหน้า ดูรายละเอียดด้านล่าง |
{ "status_code": 200, "status_message": "OK", "response": { "rows": [{ "id": 10191611434, "code": "8071-07AD1171-77238AD1", "createDate": "2020-09-14 12:26:21", "sendDate": "2020-09-14 12:26:21", "content": { "en": "Hello!" }, "url": null, "ios_title": null, "ios_subtitle": null, "ios_root_params": null, "android_header": null, "android_root_params": null, "conditions": null, "conditions_operator": "AND", "filter_code": "E3A64-A5F3C", "filter_conditions": "#In-app Purchase(≠0)", "filter_name": "Purchased something", "geozone": null, "campaignId": "", "campaignName": "", "subscription_segments": null, "open": { "C90C0-0E786": { "IOS": 0 } }, "sent": { "C90C0-0E786": { "IOS": 1 } }, "ctr": { "C90C0-0E786": 0 } }, { "id": 10191609202, "code": "41CA-83F8E0D7-7A63822B", "createDate": "2020-09-14 12:25:55", "sendDate": "2020-09-14 12:25:55", "content": { "en": "Hi!" }, "url": null, "ios_title": null, "ios_subtitle": null, "ios_root_params": null, "android_header": null, "android_root_params": null, "conditions": null, "conditions_operator": "AND", "filter_code": null, "filter_conditions": null, "filter_name": null, "geozone": null, "campaignId": "", "campaignName": "", "subscription_segments": { "2D732-BB981": "News" }, "open": { "C90C0-0E786": { "CHROME": 0, "IOS": 0 } }, "sent": { "C90C0-0E786": { "CHROME": 1, "IOS": 2 } }, "ctr": { "C90C0-0E786": 0 } }] }}{ "request":{ "auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel "source": null, // optional. Possible values are null, "CP", "API", "GeoZone", // "RSS", "AutoPush", "A/B Test" "searchBy": "applicationCode", // optional. Possible values are "", "notificationID", // "notificationCode", "applicationCode", "campaignCode" "value": "C8717-703F2", // optional. Search value set according to the "searchBy" field. "lastNotificationID": 0, // optional. Used for pagination. Last messageId from the // previous /getPushHistory call. See details below. "limitMessages": 1000 // optional. Possible value from 10 to 1000. }}เมธอดนี้จะส่งคืนข้อความ 1000 ข้อความจากบัญชีที่จัดเรียงตาม ID ข้อความ หากต้องการรับหน้าที่สอง ให้ระบุ ID ข้อความสุดท้ายของการตอบกลับก่อนหน้าในพารามิเตอร์ lastNotificationId
ประเภทข้อมูลการตอบกลับ
Anchor link toid -- int | 0code -- stringcreateDate -- string (date: %Y-%m-%d %H:%M:%S)sendDate -- string (date: %Y-%m-%d %H:%M:%S)content -- array ( dict {lang: value} | list [])title -- array ( dict {lang: value} | list [])subtitle -- array ( dict {lang: value} | list [])url -- stringios_title -- string | array ( dict {lang: value} ) | nullios_subtitle -- string | array ( dict {lang: value} ) | nullios_root_params -- dict (JSON) | nullandroid_header -- string | array ( dict {lang: value} ) | nullandroid_root_params -- dict (JSON) | nullconditions -- list (JSON) | nullconditions_operator -- string | nullfilter_code -- string | nullfilter_name -- string | nullfilter_conditions -- string | nullgeozone -- string | nullcampaignId -- string | ""campaignName -- string | ""subscription_segments (obsolete) -- list (JSON) | nulldata -- dict (JSON) | nullopen -- dict [dict [string: int]] | "" Example: 'open': {'AAAAA-BBBBB': {'IOS': 1, 'ANDROID': 1}}sent -- dict [dict [string: int]] | "" Example: 'sent': {'AAAAA-BBBBB': {'IOS': 10, 'ANDROID': 10}}ctr -- dict [string: int] | "" Example: {'AAAAA-BBBBB': 1}errors -- dict [string: int] | "" Example: {'ANDROID': 1, 'IOS': 1}cancelMessage
Anchor link toPOST https://api.pushwoosh.com/json/1.3/cancelMessage
ยกเลิกข้อความที่ตั้งเวลาไว้
Request Body
Anchor link to| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
| auth* | string | API access token จาก Pushwoosh Control Panel |
| message* | string | Message code ที่ได้รับจากการตอบกลับของ /createMessage |
{ "status_code":200, "status_message":"OK"}{ "request":{ "auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel "message": "xxxx-xxxxxxx-xxxxxx" // required. The message code obtained in /createMessage response }}รหัสสถานะ:
| รหัสสถานะ HTTP | status_code | คำอธิบาย |
|---|---|---|
| 200 | 200 | ยกเลิกข้อความสำเร็จ |
| 200 | 210 | ข้อผิดพลาดของอาร์กิวเมนต์ ดูข้อมูลเพิ่มเติมใน status_message |
| 400 | N/A | สตริงคำขอมีรูปแบบไม่ถูกต้อง |
| 500 | 500 | ข้อผิดพลาดภายใน |