Update: 2026-05-06 03:16:32
This commit is contained in:
@@ -16,7 +16,7 @@ class WhatsAppProxyService
|
||||
//"https://botmasa.intaleq.xyz/send", // mayar
|
||||
//"https://botmasa2.intaleq.xyz/send", // shad
|
||||
//"https://bootride.intaleq.xyz/send", // ramat bus
|
||||
"https://bot3.intaleq.xyz/send", // shahd
|
||||
// "https://bot3.intaleq.xyz/send", // shahd
|
||||
"https://bot5.intaleq.xyz/send", // bot5 from postman
|
||||
//"https://whatsapp.tripz-egypt.com/send" // tripz
|
||||
];
|
||||
@@ -28,11 +28,10 @@ class WhatsAppProxyService
|
||||
* @param string $message نص الرسالة
|
||||
* @return bool نجاح الإرسال
|
||||
*/
|
||||
public function sendMessage(string $to, string $message): bool
|
||||
public function sendMessage(string $to, string $message): array
|
||||
{
|
||||
if (empty($this->servers)) {
|
||||
error_log("[WhatsAppProxyService] No servers available.");
|
||||
return false;
|
||||
return ['success' => false, 'error' => 'No servers available.'];
|
||||
}
|
||||
|
||||
// اختيار سيرفر عشوائي من القائمة المتاحة لتوزيع الحمل
|
||||
@@ -62,17 +61,18 @@ class WhatsAppProxyService
|
||||
curl_close($curl);
|
||||
|
||||
if ($err) {
|
||||
error_log("[WhatsAppProxyService] cURL Error on $url: $err");
|
||||
return false;
|
||||
return ['success' => false, 'error' => $err, 'url' => $url];
|
||||
}
|
||||
|
||||
$responseData = json_decode($response, true);
|
||||
|
||||
if (!isset($responseData['success']) || $responseData['success'] !== true) {
|
||||
error_log("[WhatsAppProxyService] API Error on $url: " . $response);
|
||||
return false;
|
||||
}
|
||||
$isSuccess = isset($responseData['success']) && $responseData['success'] === true;
|
||||
|
||||
return true;
|
||||
return [
|
||||
'success' => $isSuccess,
|
||||
'response' => $responseData,
|
||||
'raw_response' => $response,
|
||||
'url' => $url,
|
||||
'payload' => $payload
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,11 +79,11 @@ if ($fp) {
|
||||
// 5. Send OTP via WhatsApp Proxy
|
||||
$whatsappService = new \App\Services\WhatsAppProxyService();
|
||||
$message = "رمز التحقق لتطبيق مُصادَق:\n*{$otp}*\n\nصالح لمدة 5 دقائق.";
|
||||
$smsSent = $whatsappService->sendMessage($phone, $message);
|
||||
$result = $whatsappService->sendMessage($phone, $message);
|
||||
|
||||
if (!$smsSent) {
|
||||
if (!$result['success']) {
|
||||
error_log("ERROR: Failed to send OTP WhatsApp to phone: {$phone}");
|
||||
json_error('عذراً، فشل في إرسال رمز التحقق. الرجاء التأكد من صحة رقم الواتساب الخاص بك والمحاولة مرة أخرى.', 500);
|
||||
json_error('عذراً، فشل في إرسال رمز التحقق. الرجاء التأكد من صحة رقم الواتساب الخاص بك والمحاولة مرة أخرى.', 500, ['whatsapp_debug' => $result]);
|
||||
}
|
||||
|
||||
// Log for development (REMOVE IN PRODUCTION!)
|
||||
@@ -91,7 +91,7 @@ if (env('APP_DEBUG', 'false') === 'true') {
|
||||
error_log("DEV OTP for {$phone}: {$otp}");
|
||||
}
|
||||
|
||||
json_success(null, 'إذا كان الرقم مسجلاً، سيتم إرسال رمز التحقق عبر واتساب');
|
||||
json_success(['whatsapp_debug' => $result], 'إذا كان الرقم مسجلاً، سيتم إرسال رمز التحقق عبر واتساب');
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user