$api_key, "senderid" => $sender_id, "number" => $mobile, "message" => $message, "type" => $type ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($ch); curl_close($ch); } function send_via_mimsms($settings, $mobile, $message) { $url = "https://api.mimsms.com/api/SmsSending/SMS"; $data = [ "UserName" => $settings['mimsms_username'], "Apikey" => $settings['mimsms_api_key'], "MobileNumber" => $mobile, "CampaignId" => null, // or you can use "null" (as a string) if required "SenderName" => $settings['mimsms_sender_id'], "TransactionType" => "T", "Message" => $message ]; $payload = json_encode($data); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); curl_setopt($ch, CURLOPT_HTTPHEADER, [ "Content-Type: application/json", "Accept: application/json" ]); $response = curl_exec($ch); curl_close($ch); } function send_via_greenweb($settings, $mobile, $message) { $to = $mobile; $token = $settings['greenweb_api_token']; $message = $message; $url = "https://api.bdbulksms.net/api.php?json"; $data= array( 'to'=>$to, 'message'=>$message, 'token'=>$token ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_ENCODING, ''); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $smsresult = curl_exec($ch); curl_close($ch); } // Helper function to validate mobile numbers function validate_mobile_number($number) { // Remove any non-digit characters $number = preg_replace('/[^0-9]/', '', $number); // Check if it's a valid Bangladeshi mobile number if (preg_match('/^(?:\+88|88)?(01[3-9]\d{8})$/', $number, $matches)) { return '880'.$matches[1]; // Return in 8801XXXXXXXXX format } return false; }