Files
Siro/loction_server/test_ride_taken.php
2026-06-29 23:09:43 +03:00

43 lines
1.2 KiB
PHP
Executable File

<?php
// test_ride_taken.php
// إعدادات الاتصال
$socketUrl = 'http://127.0.0.1:2021';
$INTERNAL_KEY = trim(file_get_contents('/home/location/.internal_socket_key'));
// بيانات المحاكاة
// يجب أن يكون نفس رقم الطلب الذي أرسلته سابقاً
$rideId = '9999';
// آيدي سائق "وهمي" (غير آيديك الحقيقي)
// لكي يفهم تطبيقك أن شخصاً آخر أخذ الطلب
$fakeDriverId = 'DRIVER_XYZ_987654321';
$postData = [
'action' => 'simulate_ride_taken',
'ride_id' => $rideId,
'taken_by_driver_id' => $fakeDriverId
];
// إرسال الطلب عبر cURL
$ch = curl_init($socketUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"x-internal-key: $internalKey"
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "Simulating Ride Taken...\n";
echo "Response: $response\n";
if ($response == 'Ride Taken Event Broadcasted') {
echo "✅ Success! All drivers should see 'Ride Taken' now.\n";
} else {
echo "❌ Failed.\n";
}
?>