Geozones API
getNearestZone
Anchor link toเรียกใช้ภายในจาก SDK ดึงพารามิเตอร์ของ geozone ที่ใกล้ที่สุดและระยะทางไปยัง geozone นั้น นอกจากนี้ยังบันทึกตำแหน่งของอุปกรณ์สำหรับการแจ้งเตือนแบบ geo push
POST https://api.pushwoosh.com/json/1.3/getNearestZoneพารามิเตอร์ของ Request body
Anchor link to| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
| application | string | ใช่ | รหัสแอปพลิเคชัน Pushwoosh |
| hwid | string | ใช่ | ID อุปกรณ์ฮาร์ดแวร์ ที่ใช้ในคำขอ /registerDevice |
| lat | string | ใช่ | ละติจูดของอุปกรณ์ |
| lng | string | ใช่ | ลองจิจูดของอุปกรณ์ |
ตัวอย่าง Request
Anchor link to{ "request": { "application": "APPLICATION_CODE", "hwid": "HWID", "lat": 10.12345, "lng": 28.12345 }}ตัวอย่าง PHP
Anchor link to// See http://gomoob.github.io/php-pushwoosh/get-nearest-zone.html
use Gomoob\Pushwoosh\Model\Request\GetNearestZoneRequest;
// Creates the request instance$request = GetNearestZoneRequest::create() ->setHwid('HWID') ->setLat(10.12345) ->setLng(28.12345);
// Call the '/getNearestZone' Web Service$response = $pushwoosh->getNearestZone($request);
if ($response->isOk()) { print 'Zone name : ' . $response->getResponse()->getName(); print 'Latitude : ' . $response->getResponse()->getLat(); print 'Longitude : ' . $response->getResponse()->getLng(); print 'Range : ' . $response->getResponse()->getRange(); print 'Distance : ' . $response->getResponse()->getDistance();} else { print 'Oops, the operation failed :-('; print 'Status code : ' . $response->getStatusCode(); print 'Status message : ' . $response->getStatusMessage();}addGeoZone
Anchor link toเพิ่ม Geozone ไปยังแอปที่ระบุ
POST https://api.pushwoosh.com/json/1.3/addGeoZoneพารามิเตอร์ของ Request body
Anchor link to| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
| auth | string | ใช่ | โทเค็นการเข้าถึง API จาก Pushwoosh Control Panel |
| application | string | ใช่ | รหัสแอปพลิเคชัน Pushwoosh |
| geozones | array | ใช่ | พารามิเตอร์ Geozone ในรูปแบบอาร์เรย์ JSON |
| geozones.name | string | ใช่ | ชื่อ Geozone |
| geozones.lat | string | จำเป็นสำหรับวงกลม | ละติจูดของ Geozone ละเว้นเมื่อตั้งค่า polygon — geozone แบบ polygon จะหาจุดศูนย์กลางของตัวเอง |
| geozones.lng | string | จำเป็นสำหรับวงกลม | ลองจิจูดของ Geozone ละเว้นเมื่อตั้งค่า polygon — geozone แบบ polygon จะหาจุดศูนย์กลางของตัวเอง |
| geozones.cooldown | integer | ใช่ | ช่วงเวลาเงียบหลังจากส่งการแจ้งเตือน (เป็นวินาที) |
| geozones.range | integer | จำเป็นสำหรับวงกลม | ระยะของ Geozone เป็นเมตร ขั้นต่ำ 50 ละเว้นเมื่อตั้งค่า polygon — geozone แบบ polygon จะหาระยะของตัวเอง |
| geozones.polygon | object | ไม่ | ทำให้ geozone เป็นรูปหลายเหลี่ยมแทนที่จะเป็นวงกลม ไม่สามารถใช้ร่วมกับ lat/lng/range — การส่งทั้งสองอย่างจะถูกปฏิเสธ ดูที่ Polygon geozones |
| geozones.content | string or object | จำเป็นหาก presetCode ว่างเปล่า | เนื้อหาข้อความของ Geozone |
| geozones.presetCode | string | จำเป็นหาก content ว่างเปล่า | Push preset ที่จะใช้แทน content |
| geozones.cluster | string | ไม่ | ระบุ null เพื่อยกเลิกการผูกคลัสเตอร์จาก Geozone |
| geozones.campaign | string | ไม่ | ระบุ null เพื่อยกเลิกการผูกแคมเปญจาก Geozone หากไม่ระบุ ค่าแคมเปญจะไม่เปลี่ยนแปลง หมายเหตุ: มีลำดับความสำคัญสูงกว่าแคมเปญใน preset |
| geozones.timetable | object | ไม่ | ตั้งค่าช่วงเวลาของตารางเวลา |
ตัวอย่าง Request
Anchor link to{ "request": { "auth": "yxoPUlwqm............pIyEX4H", // API access token from Pushwoosh Control Panel "application": "XXXXX-XXXXX", // Pushwoosh application code "geozones": [{ "name": "Statue of George", // required. Geozone name. "lat": "40.70087797", // required. Geozone latitude. "lng": "-73.931851387", // required. Geozone longitude. "cooldown": 60, // in seconds, required. Silent period after sending a notification "range": 50, // in meters, minimum 50, required. Range of the geozone. "content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", // or object "presetCode": "AAAAA-BBBBB", // optional. Push preset could be used instead of content "cluster": "GEOZONE CLUSTER CODE", // optional. Cluster's cooldown period will be applied "campaign": "CAMPAIGN_CODE", // optional. Specify null to unbind Campaign from Geozone "timetable": { // optional "timezone": 1234, // in seconds "Mon": [ // available days: Mon, Tue, Wed, Thu, Fri, Sat, Sun. Push sending { "start": "04:11", "stop": "12:00" } ], "Sun": [ { // one or two intervals "start": "01:11", "stop": "17:00" }, { "start": "18:01", "stop": "23:59" } ] } }] }}การเพิ่ม geozones หลายรายการพร้อมกัน
Anchor link togeozones รับค่าเป็นอาร์เรย์ ดังนั้นการเรียกเพียงครั้งเดียวสามารถสร้างได้ทั้งชุด ชุดข้อมูลจะถูกตรวจสอบความถูกต้องทั้งหมดก่อนที่จะมีการเขียนข้อมูลใดๆ: หากมีรายการใดถูกปฏิเสธ การเรียกจะล้มเหลวและจะไม่มีการสร้าง geozone จากคำขอนั้น ข้อผิดพลาดจะระบุรายการที่เป็นปัญหาตามตำแหน่งในอาร์เรย์ โดยนับจากศูนย์:
{ "status_code": 210, "status_message": "geozones[301]: range: range must be at least 50 meters"}แก้ไขรายการนั้นและส่งคำขออีกครั้ง เมื่อสำเร็จ GeoZones จะเก็บ ID ตัวเลขใหม่ตามลำดับเดียวกับรายการที่คุณส่ง
ชุดข้อมูลที่ใหญ่กว่า 500 รายการจะถูกยอมรับและแบ่งออกเป็นส่วนๆ ภายใน อาร์เรย์ทั้งหมดยังคงถูกตรวจสอบความถูกต้องก่อนการเขียนครั้งแรก แต่การเขียนเองนั้นไม่ใช่ atomic ข้ามส่วนต่างๆ: รายการสามารถผ่านการตรวจสอบความถูกต้องและยังคงล้มเหลวในการเขียนได้ ตัวอย่างเช่น หาก preset ที่ระบุถูกลบไปในระหว่างนั้น ในกรณีนั้น การเรียกจะส่งคืน 200 พร้อมกับ ID ที่ถูกเขียนบวกกับอาร์เรย์ Errors ที่ระบุรายการที่หยุดการทำงาน ดังนั้นจะไม่มีข้อมูลที่สร้างขึ้นสูญหาย:
{ "status_code": 200, "status_message": "OK", "response": { "GeoZones": [100016750, 100016751], "Errors": [{ "index": 2, "message": "preset not found" }] }}Errors จะไม่มีอยู่เมื่อทุกรายการถูกเขียน ดังนั้นการตอบสนองที่สำเร็จสมบูรณ์จะไม่เปลี่ยนแปลง อาร์เรย์ GeoZones ที่สั้นกว่าอาร์เรย์ที่คุณส่งหมายความว่ามีบางรายการไม่ถูกสร้างขึ้นเสมอ
Geozones แบบ Polygon
Anchor link toส่ง polygon แทน lat/lng/range เพื่อทำให้ geozone เป็นรูปหลายเหลี่ยม polygon.vertices คือวงแหวนที่เรียงลำดับของจุด {lat, lng} ที่อธิบายโครงร่างของรูปร่าง:
{ "request": { "auth": "yxoPUlwqm............pIyEX4H", "application": "XXXXX-XXXXX", "geozones": [{ "name": "Downtown mall — ground floor", "cooldown": 60, "polygon": { "vertices": [ { "lat": 40.70087797, "lng": -73.931851387 }, { "lat": 40.70112456, "lng": -73.931602211 }, { "lat": 40.70095321, "lng": -73.930987654 }, { "lat": 40.70068912, "lng": -73.931233456 } ] }, "content": "Welcome! Enjoy 15% off your first purchase today." }] }}lat, lng และ range จะถูกคำนวณจากวงแหวน — วงกลมที่อุปกรณ์ตรวจสอบจริงๆ จะมีศูนย์กลางอยู่ที่รูปร่างและมีรัศมีไปถึงจุดยอดที่ไกลที่สุด (ขั้นต่ำ 50 ม.) การส่ง polygon พร้อมกับ lat/lng/range จะถูกปฏิเสธ
คุณสามารถส่งวงแหวนแบบเปิดหรือปิดได้ — หากจุดยอดสุดท้ายซ้ำกับจุดแรก เซิร์ฟเวอร์จะลบจุดที่ซ้ำกันนั้นออกก่อนทำการตรวจสอบความถูกต้อง การตรวจสอบความถูกต้องของจุดยอดบนวงแหวนผลลัพธ์: 3 ถึง 100 จุดยอดที่แตกต่างกัน วงแหวนจะถูกปฏิเสธหากจุดต่างๆ อยู่ในแนวเส้นตรงเดียวกัน หากขอบของมันตัดกันเอง หรือหากมันข้ามเส้นแอนติเมอริเดียน
updateGeoZone
Anchor link toอัปเดตคุณสมบัติของ Geozone
POST https://api.pushwoosh.com/json/1.3/updateGeoZoneพารามิเตอร์ของ Request body
Anchor link to| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
| auth | string | ใช่ | โทเค็นการเข้าถึง API จาก Pushwoosh Control Panel |
| geoZoneId | string | ใช่ | ID ของ Geozone จากคำขอ /addGeoZone |
| name | string | ไม่ | ชื่อ Geozone ใหม่ |
| cooldown | integer | ไม่ | Cooldown ที่จะอัปเดต เป็นวินาที |
| status | integer | ไม่ | 0 - ปิดใช้งาน, 1 - เปิดใช้งาน |
| content | string | ไม่ | เนื้อหาสำหรับการแจ้งเตือน push ของ Geozone ไม่สามารถใช้กับ presetCode ได้ |
| cluster | string | ไม่ | ชื่อคลัสเตอร์ใหม่ ระบุ null เพื่อยกเลิกการผูกคลัสเตอร์จาก Geozone |
| campaign | string | ไม่ | ID แคมเปญใหม่ ระบุ null เพื่อยกเลิกการผูกแคมเปญจาก Geozone หากไม่ระบุ ค่าแคมเปญจะไม่เปลี่ยนแปลง มีลำดับความสำคัญสูงกว่าแคมเปญใน preset |
| lat | number | ไม่ | ละติจูดของ Geozone ไม่สามารถใช้ร่วมกับ polygon ได้ |
| lng | number | ไม่ | ลองจิจูดของ Geozone ไม่สามารถใช้ร่วมกับ polygon ได้ |
| range | integer | ไม่ | ระยะใหม่เป็นเมตร ไม่สามารถใช้ร่วมกับ polygon ได้ |
| polygon | object | ไม่ | วงแหวนใหม่ของจุดยอด {lat, lng} — แทนที่รูปร่างและคำนวณ lat/lng/range ใหม่จากมัน ดูที่ Polygon geozones ทำงานได้ทั้งสองทาง: ส่งไปยัง geozone วงกลมที่มีอยู่เพื่อเปลี่ยนเป็นรูปหลายเหลี่ยม หรือส่งวงแหวนว่าง ({"vertices": []}) ไปยัง geozone รูปหลายเหลี่ยมที่มีอยู่เพื่อเปลี่ยนกลับเป็นวงกลม ละเว้น polygon ทั้งหมดเพื่อคงรูปร่างเดิมไว้ การตรวจสอบความถูกต้องของจุดยอดเหมือนกับ addGeoZone |
| timetable | object | ไม่ | ตารางเวลาของ Geozone ดูข้อมูลเพิ่มเติมด้านล่าง |
ตัวอย่าง Request
Anchor link to{ "request": { "auth": "yxoPUlwqm............pIyEX4H", // required, API access token from Pushwoosh Control "geoZoneId": 100016750, // required, from /addGeoZone method "name": "new geozone name", // optional "cooldown": 222, // in seconds, optional "status": 0, // optional, 0 - deactivated, 1 - activated "presetCode": "BBBBB-AAAAA", // optional, cannot be used along with "content" "content": "new geozone content", // optional, cannot be used along with "presetCode" "cluster": "GEOZONE CLUSTER CODE", // optional. Specify null to unbind cluster from Geozone "campaign": "CAMPAIGN_CODE", // optional. Specify null to unbind Campaign from Geozone "lat": 10.56, // optional, geozone latitude "lng": 12.523, // optional, geozone longitude "range": 500, // optional, geozone range "timetable": { // optional "timezone": 1234, // in seconds "Mon": [ // available days: Mon, Tue, Wed, Thu, Fri, Sat, Sun. Push sending { "start": "04:11", "stop": "12:00" } ], "Sun": [ { // one or two intervals "start": "01:11", "stop": "17:00" }, { "start": "18:01", "stop": "23:59" } ] } }}deleteGeoZone
Anchor link toลบ Geozones ออกจากแอป
POST https://api.pushwoosh.com/json/1.3/deleteGeoZoneพารามิเตอร์ของ Request body
Anchor link to| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
| auth | string | ใช่ | โทเค็นการเข้าถึง API จาก Pushwoosh Control Panel |
| application | string | ใช่ | รหัสแอปพลิเคชัน Pushwoosh |
| geozones | string | ใช่ | อาร์เรย์ของ ID หรือ ID เดียว ของ Geozone ที่จะลบ |
ตัวอย่าง Request
Anchor link to{ "request": { "auth": "yxoPUlwqm............pIyEX4H", // required, API access token from Pushwoosh Control "application": "XXXXX-XXXXX", // required, Pushwoosh application code "geozones": [550, 526] // required, geozones IDs }}addGeoZoneCluster
Anchor link toเพิ่ม Geozone Cluster ไปยังแอป
POST https://api.pushwoosh.com/json/1.3/addGeoZoneClusterพารามิเตอร์ของ Request body
Anchor link to| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
| auth | string | ใช่ | โทเค็นการเข้าถึง API จาก Pushwoosh Control Panel |
| application | string | ใช่ | รหัสแอปพลิเคชัน Pushwoosh |
| name | string | ใช่ | ชื่อคลัสเตอร์ |
| cooldown | integer | ใช่ | ความล่าช้าก่อนที่ผู้ใช้คนเดียวจะสามารถรับข้อความเดียวกันจาก Geozone Cluster ได้อีกครั้ง เป็นวินาที |
ตัวอย่าง Request
Anchor link to{ "request": { "auth": "yxoPUlwqm............pIyEX4H", // required, API access token from Pushwoosh Control "application": "XXXXX-XXXXX", // required, Pushwoosh application code "name": "Raccoon city", // required, cluster name "cooldown": 3210 // required, in seconds }}deleteGeoZoneCluster
Anchor link toลบ Geozone Cluster ออกจากแอป
POST https://api.pushwoosh.com/json/1.3/deleteGeoZoneClusterพารามิเตอร์ของ Request body
Anchor link to| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
| auth | string | ใช่ | โทเค็นการเข้าถึง API จาก Pushwoosh Control Panel |
| application | string | ใช่ | รหัสแอปพลิเคชัน Pushwoosh |
| geoZoneCluster | string | ใช่ | ID ของ Geozone cluster ที่จะลบ |
ตัวอย่าง Request
Anchor link to{ "request": { "auth": "yxoPUlwqm............pIyEX4H", // required, API access token from Pushwoosh Control "application": "XXXXX-XXXXX", // required, Pushwoosh application code "geoZoneCluster": "EA1CE-69405" // required, cluster ID obtained from the /addGeoZoneCluster request }}listGeoZones
Anchor link toดึงรายการ Geozones สำหรับแอป
POST https://api.pushwoosh.com/json/1.3/listGeoZonesพารามิเตอร์ของ Request body
Anchor link to| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
| auth | string | ใช่ | โทเค็นการเข้าถึง API จาก Pushwoosh Control Panel |
| application | string | ใช่ | รหัสแอปพลิเคชัน Pushwoosh |
ตัวอย่าง Request
Anchor link to{ "request": { "auth": "yxoPUlwqm............pIyEX4H", // required, API access token from Pushwoosh Control "application": "XXXXX-XXXXX" // required, Pushwoosh application code }}listGeoZoneClusters
Anchor link toดึงรายการ Geozone clusters สำหรับแอป
POST https://api.pushwoosh.com/json/1.3/listGeoZoneClustersพารามิเตอร์ของ Request body
Anchor link to| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
| auth | string | ใช่ | โทเค็นการเข้าถึง API จาก Pushwoosh Control Panel |
| application | string | ใช่ | รหัสแอปพลิเคชัน Pushwoosh |
ตัวอย่าง Request
Anchor link to{ "request": { "auth": "yxoPUlwqm............pIyEX4H", // required, API access token from Pushwoosh Control "application": "XXXXX-XXXXX" // required, Pushwoosh application code }}