up
This commit is contained in:
@@ -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);
|
||||
@@ -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";
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
$_GET['debug'] = 'true';
|
||||
require_once __DIR__ . '/../api/diagnose_whatsapp.php';
|
||||
@@ -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;
|
||||
@@ -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";
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -252,8 +252,12 @@ class ServiceTestSuite {
|
||||
});
|
||||
|
||||
$this->serviceTest("Test gestión de usuarios", function() {
|
||||
$testPhone = '573168950803';
|
||||
|
||||
// Generar teléfono de prueba único para evitar colisiones
|
||||
$testPhone = '573' . rand(100000000, 999999999);
|
||||
|
||||
// Asegurar limpieza previa (por si quedó un registro previo con mismo número)
|
||||
$this->db->execute("DELETE FROM users WHERE phone_number = :phone", ['phone' => $testPhone]);
|
||||
|
||||
// Crear usuario de prueba
|
||||
$userId = $this->db->insert('users', [
|
||||
'phone_number' => $testPhone,
|
||||
|
||||
Reference in New Issue
Block a user