-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSmsManager.php
More file actions
58 lines (46 loc) · 1.29 KB
/
SmsManager.php
File metadata and controls
58 lines (46 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace App\Modules\Sms;
use SoapClient;
use Exception;
class SmsManager
{
protected string $username;
protected string $password;
protected ?string $to = null;
protected ?string $pattern = null;
public function __construct()
{
$this->username = config('sms.username');
$this->password = config('sms.password');
}
public function to(string $phone): self
{
$this->to = $phone;
return $this;
}
public function pattern(string $pattern): self
{
$this->pattern = $pattern;
return $this;
}
public function send(array $args = []): mixed
{
ini_set("soap.wsdl_cache_enabled", "0");
try {
$client = new SoapClient("http://api.payamak-panel.com/post/Send.asmx?wsdl", [
"encoding" => "UTF-8",
]);
$text = "@{$this->pattern}@" . implode(';', $args);
$data = [
"username" => $this->username,
"password" => $this->password,
"text" => $text,
"to" => $this->to,
];
return $client->SendByBaseNumber3($data)->SendByBaseNumber3Result;
} catch (Exception $e) {
report($e);
return false;
}
}
}