This commit is contained in:
lizandrogd
2026-01-21 12:44:58 -05:00
parent e6e9f76230
commit 3e57e6946c
14 changed files with 70 additions and 2 deletions
@@ -0,0 +1,7 @@
<?php
require_once __DIR__ . '/../config/config.php';
$db = Database::getInstance();
$phone = $argv[1] ?? '573022548060';
$rows = $db->fetchAll("SELECT c.id, c.message_id, c.direction, c.message_type, c.content, c.created_at, u.phone_number FROM conversations c JOIN users u ON c.user_id=u.id WHERE u.phone_number = ? ORDER BY c.created_at DESC LIMIT 5", [$phone]);
header('Content-Type: application/json');
echo json_encode($rows, JSON_PRETTY_PRINT);
+29
View File
@@ -0,0 +1,29 @@
<?php
require_once __DIR__ . '/../config/config.php';
$token = getConfigFromDB('whatsapp_token', '');
$phoneId = getConfigFromDB('whatsapp_phone_number_id', '');
$maskedToken = $token ? substr($token,0,6).'...'.substr($token,-4) : '(empty)';
echo "Phone ID: $phoneId\nToken: $maskedToken\n\n";
$url = "https://graph.facebook.com/v22.0/{$phoneId}?access_token=".urlencode($token);
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 15,
CURLOPT_SSL_VERIFYPEER => true
]);
$response = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$err = curl_error($ch);
curl_close($ch);
if ($err) {
echo "cURL error: $err\n";
exit(1);
}
echo "HTTP Code: $code\n";
echo "Response:\n";
echo $response . "\n";
$decoded = json_decode($response, true);
if ($decoded && isset($decoded['error'])) {
echo "\nDetected error message: " . ($decoded['error']['message'] ?? json_encode($decoded['error'])) . "\n";
}
+3
View File
@@ -0,0 +1,3 @@
<?php
$_GET['debug'] = 'true';
require_once __DIR__ . '/../api/diagnose_whatsapp.php';
+13
View File
@@ -0,0 +1,13 @@
<?php
// Script de prueba para ejecutar api/get_users.php en modo debug
$_GET['debug'] = 'true';
chdir(__DIR__ . '/../api');
ob_start();
try {
include 'get_users.php';
} catch (Throwable $t) {
echo "Throwable: " . $t->getMessage() . "\n";
echo $t->getTraceAsString() . "\n";
}
$out = ob_get_clean();
echo $out;
+12
View File
@@ -0,0 +1,12 @@
<?php
require_once __DIR__ . '/../config/config.php';
$wh = new WhatsAppService();
$to = '573022548060';
$message = 'Prueba de envío (desarrollo) ' . date('Y-m-d H:i:s');
try {
$res = $wh->sendTextMessage($to, $message);
echo "Response:\n";
echo json_encode($res, JSON_PRETTY_PRINT) . "\n";
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}