This commit is contained in:
lizandrogd
2026-01-21 08:28:54 -05:00
parent 7d6c3b4fb4
commit 45a11032f5
59 changed files with 315 additions and 315 deletions
+4 -4
View File
@@ -14,8 +14,8 @@ try {
if (!empty($entry['changes'])) {
foreach ($entry['changes'] as $change) {
$val = $change['value'] ?? [];
if (!empty($val['messages'])) {
foreach ($val['messages'] as $m) {
if (!empty($val['conversations'])) {
foreach ($val['conversations'] as $m) {
$mid = $m['id'] ?? null;
$from = $m['from'] ?? null;
if ($mid) {
@@ -33,9 +33,9 @@ try {
}
if (empty($missing)) {
echo "All recent messages found in conversations.\n";
echo "All recent conversations found in conversations.\n";
} else {
echo "Missing messages (not found in conversations):\n";
echo "Missing conversations (not found in conversations):\n";
foreach ($missing as $m) {
echo json_encode($m) . PHP_EOL;
}
+1 -1
View File
@@ -6,7 +6,7 @@ try {
$rows = $db->fetchAll('SELECT id, request_body, created_at FROM webhook_logs ORDER BY created_at DESC LIMIT 20');
foreach ($rows as $r) {
$rb = $r['request_body'];
$has = strpos($rb, '"messages"') !== false ? 'HAS_MESSAGES' : (strpos($rb, '"statuses"') !== false ? 'ONLY_STATUSES' : 'OTHER');
$has = strpos($rb, '"conversations"') !== false ? 'HAS_conversations' : (strpos($rb, '"statuses"') !== false ? 'ONLY_STATUSES' : 'OTHER');
echo $r['created_at'] . ' | id:' . $r['id'] . ' | ' . $has . PHP_EOL;
}
} catch (Exception $e) {
+2 -2
View File
@@ -12,8 +12,8 @@ try {
foreach ($payload['entry'] as $entry) {
foreach ($entry['changes'] as $change) {
$val = $change['value'];
if (!empty($val['messages'])) {
foreach ($val['messages'] as $message) {
if (!empty($val['conversations'])) {
foreach ($val['conversations'] as $message) {
$phone = $message['from'];
$mid = $message['id'];
$text = $message['text']['body'] ?? '';
+2 -2
View File
@@ -9,9 +9,9 @@ $payload = [
[
'changes' => [
[
'field' => 'messages',
'field' => 'conversations',
'value' => [
'messages' => [
'conversations' => [
[
'from' => '573019999900',
'id' => 'NTFTEST1',
+4 -4
View File
@@ -27,7 +27,7 @@ $payload = [
[
'changes' => [
[
'field' => 'messages',
'field' => 'conversations',
'value' => [
'messaging_product' => 'whatsapp',
'metadata' => [
@@ -37,7 +37,7 @@ $payload = [
'contacts' => [
[ 'profile' => ['name' => 'reactor'], 'wa_id' => $testPhone ]
],
'messages' => [
'conversations' => [
[
'from' => $testPhone,
'id' => '2001',
@@ -86,9 +86,9 @@ $payload2 = [
[
'changes' => [
[
'field' => 'messages',
'field' => 'conversations',
'value' => [
'messages' => [
'conversations' => [
[
'from' => $testPhone2,
'id' => '2002',
+1 -1
View File
@@ -1 +1 @@
{"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"}}]}}]}]}
{"object":"whatsapp_business_account","entry":[{"id":"0","changes":[{"field":"conversations","value":{"messaging_product":"whatsapp","metadata":{"display_phone_number":"16505551111","phone_number_id":"123456123"},"contacts":[{"profile":{"name":"test user name"},"wa_id":"16315551181"}],"conversations":[{"from":"16315551181","id":"ABGGFlA5Fpa","timestamp":"1504902988","type":"text","text":{"body":"this is a text message"}}]}}]}]}
+4 -4
View File
@@ -11,7 +11,7 @@ $payload = [
"id" => "0",
"changes" => [
[
"field" => "messages",
"field" => "conversations",
"value" => [
"messaging_product" => "whatsapp",
"metadata" => [
@@ -24,7 +24,7 @@ $payload = [
"wa_id" => "16315551181"
]
],
"messages" => [
"conversations" => [
[
"from" => "16315551181",
"id" => "ABGGFlA5Fpa",
@@ -54,7 +54,7 @@ try {
"id" => "0",
"changes" => [
[
"field" => "messages",
"field" => "conversations",
"value" => [
"messaging_product" => "whatsapp",
"metadata" => [
@@ -67,7 +67,7 @@ try {
"wa_id" => "16315551181"
]
],
"messages" => [
"conversations" => [
[
"from" => "16315551181",
"id" => "REACTION1",