You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
852 B
PHTML

<?php
namespace Base\Tool;
class TaskClient
{
const SUCCESS = '0000';
protected $client;
public function __construct()
{
$this->client = new Client([
'base_uri' => C('TASK_URL'),
'timeout' => 10.0,
]);
}
protected function post($uri, $data)
{
$response = $this->client->post($uri, [
'verify' => false,
'form_params' => $data
]);
$result = (string)$response->getBody();
return json_decode($result, true);
}
public function sendSms($mobile, $type = 'common')
{
$result = $this->post('/message/sms-send', ['mobile' => $mobile, 'type' => $type]);
}
public function checkSms($mobile, $code)
{
$result = $this->post('/message/sms-check', ['mobile' => $mobile, 'code' => $code]);
}
}