add SMSpanel
This commit is contained in:
@@ -7,7 +7,9 @@ use App\Models\User;
|
||||
use App\Models\Customer;
|
||||
use App\Models\Setting;
|
||||
use App\Models\Message;
|
||||
use App\Exceptions\SmsBlockedException;
|
||||
use App\Services\ConfigService;
|
||||
use App\Services\SmsBilling\SmsGatewayService;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
@@ -103,9 +105,6 @@ class Controller extends BaseController
|
||||
|
||||
public static function SendMessage($to, $msg ,$is_send = false,$force_method ='null')
|
||||
{
|
||||
|
||||
$config = app(ConfigService::class);
|
||||
// $config = config('message', false);
|
||||
$credentials = [
|
||||
"telegram" => [
|
||||
"token" => self::Config('telegram_bot_token')
|
||||
@@ -148,44 +147,28 @@ class Controller extends BaseController
|
||||
|
||||
//SMS
|
||||
if ($send_sms or $force_method=="sms") {
|
||||
/* $endpoint = "https://www.0098sms.com/sendsmslink.aspx";
|
||||
$response = Http::withoutVerifying()->get($endpoint, [
|
||||
'FROM' => $credentials['sms']['sender'],
|
||||
'TO' => $to,
|
||||
'TEXT' => trim($msg),
|
||||
'USERNAME' => $credentials['sms']['user_name'],
|
||||
'PASSWORD' => $credentials['sms']['password'],
|
||||
'DOMAIN' => '0098',
|
||||
]);
|
||||
$platforms[] = "0098:{$to}";*/
|
||||
|
||||
try {
|
||||
$http = Http::timeout(15)
|
||||
->withHeaders([
|
||||
'Content-Type' => 'application/json',
|
||||
'secret_key' => 'f21debfb-83ac-4624-a2f4-f08375043181',
|
||||
]);
|
||||
$gateway = app(SmsGatewayService::class);
|
||||
|
||||
$curlOptions = self::httpClientOptions();
|
||||
if ($curlOptions !== []) {
|
||||
$http = $http->withOptions($curlOptions);
|
||||
if ($force_method == "sms") {
|
||||
$smsResult = $gateway->sendOrThrow($to, trim($msg), 'notification');
|
||||
} else {
|
||||
$smsResult = $gateway->send($to, trim($msg), 'notification');
|
||||
}
|
||||
|
||||
$response = $http->post('http://185.231.112.101/api/createsms', [
|
||||
'phone' => $to,
|
||||
'host' => $config->Config('name_fa') ?? gethostname(),
|
||||
'text' => trim($msg),
|
||||
'platform' => 'rayegansms',
|
||||
]);
|
||||
|
||||
$platforms[] = $response->successful()
|
||||
? "rayegansms:{$to}"
|
||||
: "rayegansms_failed:{$to}:{$response->status()}";
|
||||
if ($smsResult->blocked) {
|
||||
$platforms[] = "blocked:{$to}";
|
||||
} elseif ($smsResult->sent && $smsResult->provider) {
|
||||
$platforms[] = "{$smsResult->provider}:{$to}";
|
||||
} else {
|
||||
$platforms[] = "sms_failed:{$to}";
|
||||
}
|
||||
} catch (SmsBlockedException $e) {
|
||||
throw $e;
|
||||
} catch (\Throwable $e) {
|
||||
report($e);
|
||||
$platforms[] = "rayegansms_error:{$to}";
|
||||
$platforms[] = "sms_error:{$to}";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Message::create([
|
||||
|
||||
Reference in New Issue
Block a user