Constants

DEFAULT_TIMEOUT

DEFAULT_TIMEOUT = 5.0

ENDPOINT_URL

ENDPOINT_URL = 'https://dysmsapi.ap-southeast-1.aliyuncs.com'

ENDPOINT_ACTION

ENDPOINT_ACTION = 'SendMessageWithTemplate'

ENDPOINT_VERSION

ENDPOINT_VERSION = '2018-05-01'

ENDPOINT_FORMAT

ENDPOINT_FORMAT = 'JSON'

ENDPOINT_REGION_ID

ENDPOINT_REGION_ID = 'ap-southeast-1'

ENDPOINT_SIGNATURE_METHOD

ENDPOINT_SIGNATURE_METHOD = 'HMAC-SHA1'

ENDPOINT_SIGNATURE_VERSION

ENDPOINT_SIGNATURE_VERSION = '1.0'

Properties

$config

$config : \Overtrue\EasySms\Support\Config

Type

Config

$options

$options : array

Type

array

$timeout

$timeout : float

Type

float

Methods

__construct()

__construct(array  $config) : mixed

Gateway constructor.

Parameters

array $config

Returns

mixed —

getTimeout()

getTimeout() : int|mixed

Return timeout.

Returns

int|mixed —

setTimeout()

setTimeout(int  $timeout) : $this

Set timeout.

Parameters

int $timeout

Returns

$this —

getConfig()

getConfig() : \Overtrue\EasySms\Support\Config

Returns

\Overtrue\EasySms\Support\Config —

setConfig()

setConfig(\Overtrue\EasySms\Support\Config  $config) : $this

Parameters

\Overtrue\EasySms\Support\Config $config

Returns

$this —

setGuzzleOptions()

setGuzzleOptions( $options) : $this

Parameters

$options

Returns

$this —

getGuzzleOptions()

getGuzzleOptions() : array

Returns

array —

getName()

getName() : string

Get gateway name.

Returns

string —

send()

send(\Overtrue\EasySms\Contracts\PhoneNumberInterface  $to, \Overtrue\EasySms\Contracts\MessageInterface  $message, \Overtrue\EasySms\Support\Config  $config) : array

Parameters

\Overtrue\EasySms\Contracts\PhoneNumberInterface $to
\Overtrue\EasySms\Contracts\MessageInterface $message
\Overtrue\EasySms\Support\Config $config

Throws

\Overtrue\EasySms\Exceptions\GatewayErrorException

Returns

array —

get()

get(string  $endpoint, array  $query = [], array  $headers = []) : \Psr\Http\Message\ResponseInterface|array|string

Make a get request.

Parameters

string $endpoint
array $query
array $headers

Returns

\Psr\Http\Message\ResponseInterface|array|string —

post()

post(string  $endpoint, array  $params = [], array  $headers = []) : \Psr\Http\Message\ResponseInterface|array|string

Make a post request.

Parameters

string $endpoint
array $params
array $headers

Returns

\Psr\Http\Message\ResponseInterface|array|string —

postJson()

postJson( $endpoint, array  $params = [], array  $headers = []) : \Psr\Http\Message\ResponseInterface|array|string

Make a post request with json params.

Parameters

$endpoint
array $params
array $headers

Returns

\Psr\Http\Message\ResponseInterface|array|string —

request()

request(string  $method, string  $endpoint, array  $options = []) : \Psr\Http\Message\ResponseInterface|array|string

Make a http request.

Parameters

string $method
string $endpoint
array $options

http://docs.guzzlephp.org/en/latest/request-options.html

Returns

\Psr\Http\Message\ResponseInterface|array|string —

getBaseOptions()

getBaseOptions() : array

Return base Guzzle options.

Returns

array —

getHttpClient()

getHttpClient(array  $options = []) : \GuzzleHttp\Client

Return http client.

Parameters

array $options

Returns

\GuzzleHttp\Client —

unwrapResponse()

unwrapResponse(\Psr\Http\Message\ResponseInterface  $response) : \Psr\Http\Message\ResponseInterface|array|string

Convert response contents to json.

Parameters

\Psr\Http\Message\ResponseInterface $response

Returns

\Psr\Http\Message\ResponseInterface|array|string —

generateSign()

generateSign(array  $params) : string

Generate sign

Parameters

array $params

Returns

string —