up
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
ini_set('display_errors',1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
require_once __DIR__ . '/../api/webhook.php';
|
||||
|
||||
$payload = [
|
||||
"object" => "whatsapp_business_account",
|
||||
"entry" => [
|
||||
[
|
||||
"id" => "0",
|
||||
"changes" => [
|
||||
[
|
||||
"field" => "messages",
|
||||
"value" => [
|
||||
"messaging_product" => "whatsapp",
|
||||
"metadata" => [
|
||||
"display_phone_number" => "16505551111",
|
||||
"phone_number_id" => "123456123"
|
||||
],
|
||||
"contacts" => [
|
||||
[
|
||||
"profile" => ["name" => "test user name"],
|
||||
"wa_id" => "16315551181"
|
||||
]
|
||||
],
|
||||
"messages" => [
|
||||
[
|
||||
"from" => "16315551181",
|
||||
"id" => "ABGGFlA5Fpa",
|
||||
"timestamp" => "1504902988",
|
||||
"type" => "text",
|
||||
"text" => ["body" => "this is a text message"]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
try {
|
||||
$w = new WhatsAppWebhook();
|
||||
echo "Webhook instance created\n";
|
||||
$result = $w->processPayload($payload);
|
||||
echo "processPayload result: " . ($result ? 'true' : 'false') . "\n";
|
||||
|
||||
// Simular reacción entrante
|
||||
$reactionPayload = [
|
||||
"object" => "whatsapp_business_account",
|
||||
"entry" => [
|
||||
[
|
||||
"id" => "0",
|
||||
"changes" => [
|
||||
[
|
||||
"field" => "messages",
|
||||
"value" => [
|
||||
"messaging_product" => "whatsapp",
|
||||
"metadata" => [
|
||||
"display_phone_number" => "16505551111",
|
||||
"phone_number_id" => "123456123"
|
||||
],
|
||||
"contacts" => [
|
||||
[
|
||||
"profile" => ["name" => "reactor"],
|
||||
"wa_id" => "16315551181"
|
||||
]
|
||||
],
|
||||
"messages" => [
|
||||
[
|
||||
"from" => "16315551181",
|
||||
"id" => "REACTION1",
|
||||
"timestamp" => "1504902990",
|
||||
"type" => "reaction",
|
||||
"reaction" => ["message_id" => "ABGGFlA5Fpa", "emoji" => "❤️"]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$r2 = $w->processPayload($reactionPayload);
|
||||
echo "processReaction result: " . ($r2 ? 'true' : 'false') . "\n";
|
||||
|
||||
} catch (Throwable $t) {
|
||||
echo "Fatal: " . $t->getMessage() . "\n";
|
||||
echo $t->getTraceAsString() . "\n";
|
||||
}
|
||||
|
||||
// Show last lines of system log
|
||||
$log = __DIR__ . '/../logs/system.log';
|
||||
if (file_exists($log)) {
|
||||
echo "-- Last log lines --\n";
|
||||
$lines = array_slice(file($log), -40);
|
||||
foreach ($lines as $line) echo $line;
|
||||
} else {
|
||||
echo "No log file found\n";
|
||||
}
|
||||
Reference in New Issue
Block a user