guzzle header authorization

Solutions on MaxInterview for guzzle header authorization by the best coders in the world

showing results for - "guzzle header authorization"
Héloïse
20 Nov 2018
1public function __construct()
2    {
3        $this->client = new Client();
4        $this->sms_gate_url = config('app.sms_gate.url');
5        $this->sms_gate_username = config('app.sms_gate.username');
6        $this->sms_gate_password = config('app.sms_gate.password');
7    }
8
9
10public function sendSms(string $phone, string $message)
11    {
12        try {
13            $this->client->post($this->sms_gate_url . 'send', [
14                'auth' => [$this->sms_gate_username, $this->sms_gate_password],
15
16                'json' => [
17                    "messages" => [
18                        [
19                            "recipient" => $phone,
20                            "message-id" => "itrust" . strval(time()),
21
22                            "sms" => [
23                                "originator" => "3700",
24                                "content" => [
25                                    "text" => $message
26                                ]
27                            ]
28                        ]
29                    ]
30                ]
31            ]);
32        } catch (\Exception $ex) {
33            Log::error($ex);
34        }
35    }