up
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../config/config.php';
|
||||
try {
|
||||
$db = Database::getInstance();
|
||||
$row = $db->fetch('SELECT * FROM conversations WHERE message_id = :mid', ['mid' => 'wamid.TEST123']);
|
||||
if ($row) {
|
||||
echo "FOUND:\n" . json_encode($row, JSON_PRETTY_PRINT) . "\n";
|
||||
} else {
|
||||
echo "NOT FOUND\n";
|
||||
}
|
||||
} catch (Throwable $t) {
|
||||
echo "Error: " . $t->getMessage() . "\n";
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
// Script para reproducir payload de ejemplo y verificar que media_url se guarde como URL cuando existe
|
||||
require_once __DIR__ . '/../config/config.php';
|
||||
require_once __DIR__ . '/../api/webhook.php';
|
||||
|
||||
$sample = json_decode('{
|
||||
"object": "whatsapp_business_account",
|
||||
"entry": [
|
||||
{
|
||||
"id": "639871912520412",
|
||||
"changes": [
|
||||
{
|
||||
"value": {
|
||||
"messaging_product": "whatsapp",
|
||||
"metadata": {
|
||||
"display_phone_number": "573053370116",
|
||||
"phone_number_id": "959898150536936"
|
||||
},
|
||||
"contacts": [
|
||||
{
|
||||
"profile": { "name": "Usite" },
|
||||
"wa_id": "573168950803"
|
||||
}
|
||||
],
|
||||
"messages": [
|
||||
{
|
||||
"from": "573168950803",
|
||||
"id": "wamid.TEST123",
|
||||
"timestamp": "1769010028",
|
||||
"type": "image",
|
||||
"image": {
|
||||
"mime_type": "image/jpeg",
|
||||
"sha256": "uzRfL5tvbqab4eorbpRrPr4Simdfknt0pRxHK5VGqOo=",
|
||||
"id": "1211305863907885",
|
||||
"url": "https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1211305863907885&source=webhook&ext=1769010330&hash=EXAMPLE"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"field": "messages"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}', true);
|
||||
|
||||
try {
|
||||
$webhook = new WhatsAppWebhook();
|
||||
$ok = $webhook->processPayload($sample);
|
||||
echo "processPayload returned: " . ($ok ? 'true' : 'false') . "\n";
|
||||
|
||||
// Consultar DB para ver entrada
|
||||
$db = Database::getInstance();
|
||||
$row = $db->fetch("SELECT * FROM conversations WHERE message_id = :mid", ['mid' => 'wamid.TEST123']);
|
||||
echo json_encode($row, JSON_PRETTY_PRINT);
|
||||
} catch (Throwable $t) {
|
||||
echo "Error: " . $t->getMessage() . "\n";
|
||||
echo $t->getTraceAsString();
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../config/config.php';
|
||||
require_once __DIR__ . '/../api/webhook.php';
|
||||
|
||||
$sample = json_decode('{
|
||||
"object": "whatsapp_business_account",
|
||||
"entry": [
|
||||
{
|
||||
"id": "639871912520412",
|
||||
"changes": [
|
||||
{
|
||||
"value": {
|
||||
"messaging_product": "whatsapp",
|
||||
"metadata": {
|
||||
"display_phone_number": "573053370116",
|
||||
"phone_number_id": "959898150536936"
|
||||
},
|
||||
"contacts": [
|
||||
{
|
||||
"profile": { "name": "Usite" },
|
||||
"wa_id": "573168950803"
|
||||
}
|
||||
],
|
||||
"messages": [
|
||||
{
|
||||
"from": "573168950803",
|
||||
"id": "wamid.TESTURL",
|
||||
"timestamp": "1769010028",
|
||||
"type": "image",
|
||||
"image": {
|
||||
"mime_type": "image/jpeg",
|
||||
"sha256": "uzRfL5tvbqab4eorbpRrPr4Simdfknt0pRxHK5VGqOo=",
|
||||
"id": "1211305863907885",
|
||||
"url": "https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1211305863907885&source=webhook&ext=1769010330&hash=EXAMPLE"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"field": "messages"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}', true);
|
||||
|
||||
try {
|
||||
$webhook = new WhatsAppWebhook();
|
||||
$ok = $webhook->processPayload($sample);
|
||||
echo "processPayload returned: " . ($ok ? 'true' : 'false') . "\n";
|
||||
|
||||
$db = Database::getInstance();
|
||||
$row = $db->fetchAll('SELECT * FROM conversations WHERE message_id LIKE :mid', ['mid' => '%TESTURL%']);
|
||||
echo "Rows matching TESTURL: " . count($row) . "\n";
|
||||
echo json_encode($row, JSON_PRETTY_PRINT) . "\n";
|
||||
} catch (Throwable $t) {
|
||||
echo "Error: " . $t->getMessage() . "\n";
|
||||
echo $t->getTraceAsString();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../config/config.php';
|
||||
try {
|
||||
$db = Database::getInstance();
|
||||
$rows = $db->fetchAll('SELECT * FROM conversations ORDER BY created_at DESC LIMIT 5');
|
||||
echo json_encode($rows, JSON_PRETTY_PRINT);
|
||||
} catch (Throwable $t) {
|
||||
echo "Error: " . $t->getMessage() . "\n";
|
||||
}
|
||||
Reference in New Issue
Block a user