Add a simpler URL to send a sms with nothing but a GET request and an URL
This commit is contained in:
parent
2be8242d5e
commit
5c697b5240
|
@ -304,6 +304,47 @@ namespace controllers\publics;
|
||||||
return $this->json($return);
|
return $this->json($return);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simplest method to send a SMS immediately with nothing but a URL and a GET query
|
||||||
|
* @param string $_GET['to'] = Phone number to send sms to
|
||||||
|
* @param string $_GET['text'] = Text of the SMS
|
||||||
|
* @param ?int $_GET['id_phone'] = Id of the phone to use, if null use a random phone
|
||||||
|
*/
|
||||||
|
public function get_send_sms()
|
||||||
|
{
|
||||||
|
$to = \controllers\internals\Tool::parse_phone($_GET['to'] ?? '');
|
||||||
|
$text = $_GET['text'] ?? false;
|
||||||
|
$id_phone = empty($_GET['id_phone']) ? null : $_GET['id_phone'];
|
||||||
|
|
||||||
|
if (!$to || !$text)
|
||||||
|
{
|
||||||
|
$return = self::DEFAULT_RETURN;
|
||||||
|
$return['error'] = self::ERROR_CODES['MISSING_PARAMETER'];
|
||||||
|
$return['message'] = self::ERROR_MESSAGES['MISSING_PARAMETER'] . ($to ? '' : 'to ') . ($text ? '' : 'text');
|
||||||
|
$this->auto_http_code(false);
|
||||||
|
|
||||||
|
return $this->json($return);
|
||||||
|
}
|
||||||
|
$at = (new \DateTime())->format('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
$scheduled_id = $this->internal_scheduled->create($this->user['id'], $at, $text, $id_phone);
|
||||||
|
if (!$scheduled_id)
|
||||||
|
{
|
||||||
|
$return = self::DEFAULT_RETURN;
|
||||||
|
$return['error'] = self::ERROR_CODES['CANNOT_CREATE'];
|
||||||
|
$return['message'] = self::ERROR_MESSAGES['CANNOT_CREATE'];
|
||||||
|
$this->auto_http_code(false);
|
||||||
|
|
||||||
|
return $this->json($return);
|
||||||
|
}
|
||||||
|
|
||||||
|
$return = self::DEFAULT_RETURN;
|
||||||
|
$return['response'] = $scheduled_id;
|
||||||
|
$this->auto_http_code(true);
|
||||||
|
|
||||||
|
return $this->json($return);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schedule a message to be send.
|
* Schedule a message to be send.
|
||||||
*
|
*
|
||||||
|
|
|
@ -221,6 +221,9 @@
|
||||||
'/api/invalid_number/',
|
'/api/invalid_number/',
|
||||||
'/api/invalid_number/{page}/',
|
'/api/invalid_number/{page}/',
|
||||||
],
|
],
|
||||||
|
'get_send_sms' => [
|
||||||
|
'/api/send-sms/',
|
||||||
|
],
|
||||||
'post_scheduled' => [
|
'post_scheduled' => [
|
||||||
'/api/scheduled/',
|
'/api/scheduled/',
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue