HEX
Server: LiteSpeed
System: Linux s12873.lon1.stableserver.net 5.14.0-611.11.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Dec 3 09:47:37 EST 2025 x86_64
User: jairicem (1242)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /home/jairicem/4pfxclusive.ng/vendor/tecdiary/sms/src/Gateways/BulksmsGateway.php
<?php

namespace Tecdiary\Sms\Gateways;

class BulksmsGateway implements SmsGatewayInterface
{
    public $config;
    public $response = '';

    protected $params = [];
    protected $request = '';
    protected $url = '';

    public function __construct($config)
    {
        $this->config = $config;
        $this->params['msisdn'] = '';
        $this->params['message'] = '';
        $this->params['username'] = $this->config[$this->config['gateway']]['username'];
        $this->params['password'] = $this->config[$this->config['gateway']]['password'];
        $this->url = $this->config[$this->config['gateway']]['eapi_url']."/submission/send_sms/2/2.0?";
    }

    public function getUrl()
    {
        return $this->url.http_build_query($this->params);
    }

    public function sendSms($mobile, $message)
    {
        $this->params['msisdn'] = $mobile;
        $this->params['message'] = $message;
        $client = new \GuzzleHttp\Client(['headers' => ['Accept' => 'application/json']]);
        try {
            $response = $client->get($this->getUrl())->getBody()->getContents();
            $this->response = explode('|', $response);
            if ($this->response[0] > 1) {
                throw new \Exception($response);
            }
        } catch (\Exception $e) {
            $this->response = ['error' => $e->getMessage()];
        }
        return $this;
    }

    public function response()
    {
        return $this->response;
    }
}