1 | <?php |
||
9 | class Avstelecomsms |
||
10 | { |
||
11 | protected $client; |
||
12 | |||
13 | public function __construct() |
||
14 | { |
||
15 | // |
||
16 | } |
||
17 | /** |
||
18 | * Undocumented function |
||
19 | * |
||
20 | * @param string $phone E.164 2376XXXXXXX |
||
21 | * @param string $message |
||
22 | * @return bool |
||
23 | */ |
||
24 | public function send(string $phone, string $message) |
||
25 | { |
||
26 | $timestamp = time(); |
||
27 | try { |
||
28 | $response = Http::post('http://54.37.231.5:8090/bulksms', [ |
||
29 | 'id' => config('avstelecomsms.id'), |
||
30 | 'timestamp' => $timestamp, |
||
31 | 'signature' => hash_hmac('SHA1', config('avstelecomsms.token') . $timestamp, config('avstelecomsms.secret')), |
||
32 | 'phonenumber' => $this->getPhone($phone), |
||
33 | 'sms' => $message, |
||
34 | 'schedule' => '' |
||
35 | ]); |
||
36 | $data = $response->json(); |
||
37 | |||
38 | if ($data['status'] != 200) { |
||
39 | return false; |
||
40 | } |
||
41 | return true; |
||
42 | } catch (Exception $e) { |
||
43 | return false; |
||
44 | } |
||
45 | } |
||
46 | |||
47 | private function getPhone(string $phone): string |
||
53 | } |
||
54 |