واجهة برمجة تطبيقات واتساب (WhatsApp API)
createWhatsAppMessage
Anchor link toتُستخدم لإرسال رسائل واتساب إلى المستخدمين
POST https://api.pushwoosh.com/json/1.3/createWhatsAppMessage
نص الطلب
Anchor link to| الاسم | مطلوب | النوع | الوصف |
|---|---|---|---|
| auth* | نعم | string | رمز الوصول إلى API من لوحة تحكم Pushwoosh. |
| application* | نعم | string | رمز تطبيق Pushwoosh |
| notifications* | نعم | array | إعدادات المحتوى. مصفوفة JSON من معلمات الرسالة. انظر التفاصيل أدناه. |
معلمات الإشعار
Anchor link to| الاسم | مطلوب | النوع | الوصف |
|---|---|---|---|
| send_date* | نعم | string | تاريخ ووقت إرسال الإشعار. استخدم التنسيق YYYY-MM-DD HH:mm أو 'now' للإرسال فورًا. |
| content | مطلوب إذا لم يتم توفير content_id. | string | المحتوى النصي لرسالة واتساب. |
| content_id | مطلوب إذا لم يتم توفير content. | string | معرّف لقالب واتساب تمت الموافقة عليه مسبقًا من حساب Meta الخاص بك. |
| devices* | نعم | array | رقم هاتف العميل (يجب أن يكون مرتبطًا بـ User ID باستخدام /registerDevice ومحددًا في معلمة hwid، أو استخدم use_auto_registration). يمكن تحديد رقم واحد فقط هنا. |
| use_auto_registration | لا | boolean | إذا تم تعيينه على true، فسيتم تسجيل رقم الهاتف المحدد في معلمة devices تلقائيًا. |
| content_variables | لا | object | متغيرات المحتوى لتخصيص محتوى الرسالة. سيتم استبدال كل عنصر نائب بالقيم الديناميكية المقابلة. |
| button_url_variables | لا | object | متغيرات URL الديناميكية للأزرار. يمثل كل مفتاح فهرس زر، وقيمته هي المتغير الديناميكي الذي سيتم استبداله في عنوان URL الخاص بالزر. ملاحظة: يبدأ فهرس الأزرار من 0، حيث يكون الزر الأول هو 0، والثاني هو 1، وهكذا. |
| header_variables | لا | object | متغيرات للرأس في رسالة قالب واتساب. حدد type (على سبيل المثال، text، image، video، document) والقيمة المقابلة. مثال: "header_variables": {"image": "https://image-url.png"} |
| preset | لا | string | رمز إعداد واتساب المسبق (WhatsApp Preset Code) من لوحة التحكم الخاصة بك. |
| language | لا | string | اللغة المحلية لقالب واتساب (يجب أن تتطابق مع اللغة المحلية في محرر قوالب واتساب في Meta). الافتراضي: "en_US". مثال: "en_GB". |
مثال على الطلب
Anchor link to{ "request": { "application": "12XXX-67XXX", // required. Pushwoosh application code. "auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel. "notifications": [{ "send_date": "now", // required. YYYY-MM-DD HH:mm OR "now". "content": "Hello! {{1}}", // required if content_id is not provided. Message text. "content_id": "hello_world", // required if content is not provided. WhatsApp template identifier. "devices": ["whatsapp:+1234567890"], // required. Customer WhatsApp phone number (must be associated // with a UserId using /registerDevice and specified in // the "hwid" parameter or use "use_auto_registration"). // Only one WhatsApp number can be specified here. "preset": "XXXXX-XXXXX", // optional. WhatsApp Preset Code from your Control Panel. "content_variables": { // optional. Content variables to customize the message content. "1": "John" }, "header_variables": { // optional. Variables for the WhatsApp message header. "image": "https://image-url.png" }, "language": "en_GB", // optional. Language locale for the WhatsApp template (must match the locale in Meta WhatsApp template editor). Default: "en_US". "use_auto_registration": true // optional. Automatically register WhatsApp number specified // in "devices" parameter. }] }}مثال: إرسال رمز مصادقة ثنائية عبر واتساب
Anchor link to{ "request": { "application":"APP_CODE", "auth":"AUTH_TOKEN", "notifications":[{ "send_date":"now", "content_id":"replace_with_your_meta_two_factor_template_name", "content_variables":{"1":"AUTH_CODE"}, "button_url_variables":{"0":"AUTH_CODE"}, "devices":["whatsapp:REPLACE_WITH_YOUR_PHONE_NO"] }] }}مثال على الاستجابة
Anchor link to{ "status_code": 200, "status_message": "OK", "response": { "Messages": [ "9648-0B10EXXX-0D9F2XXX" ] }}استجابة الخطأ
Anchor link to{ "status_code": 210, "status_message": "Invalid devices list. \"devices\" must be an array.", "response": { "Messages": [] }}