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.

40 lines
907 B
PHP

<?php
namespace Base\Tool;
use GuzzleHttp\Client;
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, $clientIp, $type = 'common')
{
return $this->post('/message/sms-send', ['mobile' => $mobile, 'type' => $type, 'client_ip' => $clientIp]);
}
public function checkSms($mobile, $code)
{
return $this->post('/message/sms-check', ['mobile' => $mobile, 'code' => $code]);
}
}