共有

Webhook は、当社のプラットフォームの最も便利な機能の 1 つです。これにより、開発者とサイト所有者はデバイスまたは WhatsApp サーバーからのイベントをリッスンできるようになり、自動化されたタスクの作成に役立ちます。この関数は、SMS、WhatsApp チャット、ussd 応答、Android 通知などのイベントのみを受信するために特別に設計されています。

投稿日: 2月 10, 2023 - 1,355 ビュー

使用例

  • SMS と WhatsApp の自動返信ボットを作成します。
  • メッセージとチャットを受信時に独自のデータベースに保存します。
  • 受信時に通知を独自のデータベースに保存します。
  • USSD 応答を受信時に独自のデータベースに保存します。
  • 指定された電子メール アドレスにペイロードを送信します。
  • Facebook から通知を受け取ったら、SMS/チャットを送信します。
  • アプリから通知を受け取ったら何かをします。

使い方

システムは両方のソースから受信イベントを取得し、その後 Webhook URL が呼び出され、ペイロード データが送信されます。Webhook サーバーがそれを受信すると、そのペイロードを使用して自分で何でもできるようになります。効率的な配信を確保するために、ペイロードはPOSTメソッドで送信されます。


flow
 

ペイロード構造

ペイロードの構造は単純です。ペイロードのタイプを確認してから、データ本体のコンテンツを処理するだけです。

# sms
[
    "type" => "sms", // type of payload: received sms
    "data" => [
        "id" => 2, // unique id from the system
        "rid" => 10593, // unique id from the device
        "sim" => 1, // sim card slot
        "device" => "00000000-0000-0000-d57d-f30cb6a89289", // device unique id
        "phone" => "+639760713666", // sender phone number
        "message" => "Hello World!", // message
        "timestamp" => 1645684231 // receive timestamp
    ]
]
# whatsapp
[
    "type" => "whatsapp", // type of payload: received whatsapp chat
    "data" => [
        "id" => 2, // unique id from the system
        "wid" => "+639760713666", // whatsapp account phone number
        "phone" => "+639760666713", // sender phone number
        "message" => "Hello World!", // message
        "timestamp" => 1645684231 // receive timestamp
    ]
]
# ussd
[
    "type" => "ussd", // type of payload: received ussd response
    "data" => [
        "id" => 98, // unique id from the system
        "sim" => 1, // sim card slot
        "device" => "00000000-0000-0000-d57d-f30cb6a89289", // device unique id
        "code" => "*143#", // ussd code
        "response" => "Sorry! You are not allowed to use this service.", // ussd response
        "timestamp" => 1645684231 // receive timestamp
    ]
]
# 通知
[
    "type" => "notification", // type of payload: received notification
    "data" => [
        "id" => 77, // unique id from the system
        "device" => "00000000-0000-0000-d57d-f30cb6a89289", // device unique id
        "package" => "com.facebook.katana", // application package name
        "title" => "Someone commented on your post!", // notification title
        "content" => "Someone commented on your post!", // notification content
        "timestamp" => 1645684231 // receive timestamp
    ]
]

コード例

 Webhooks)

    /**
     * Validate webhook secret
     */

    if(isset($request["secret"]) && $request["secret"] == $secret):
        // Valid webhook secret
        $payloadType = $request["type"];
        $payloadData = $request["data"];

        // do something with the payload
        print_r($payloadType);
        print_r($payloadData);
    else:
        // Invalid webhook secret
    endif;

APKファイルをダウンロード

Android スマートフォンに APK ファイルをダウンロードしてインストールします

github download App SmsNotif download App
ウイルスチェック済み APKファイルの詳細
image-1
image-2