mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-04-20 16:37:48 +02:00
Add octopsuh shortcode adapter, still testing. Add callback reception support. Add callback show in adapter.
This commit is contained in:
parent
89cb3db678
commit
6ad299f21e
14 changed files with 591 additions and 42 deletions
|
@ -90,14 +90,10 @@ class TwilioVirtualNumberAdapter implements AdapterInterface
|
|||
*/
|
||||
public static function meta_description(): string
|
||||
{
|
||||
$callback = \descartes\Router::url('Callback', 'update_sended_status', ['adapter_uid' => self::meta_uid()], ['api_key' => $_SESSION['user']['api_key'] ?? '<your_api_key>']);
|
||||
$credentials_url = 'https://www.twilio.com/console';
|
||||
|
||||
return '
|
||||
Solution de SMS avec numéro virtuel proposé par <a target="_blank" href="https://www.twilio.com/sms">Twilio</a>. Pour trouver vos clés API Twilio <a target="_blank" href="' . $credentials_url . '">cliquez ici.</a>
|
||||
<br/>
|
||||
<br/>
|
||||
<div class="alert alert-info">Adresse URL de callback de changement d\'état : <b>' . $callback . '</b></div>
|
||||
';
|
||||
}
|
||||
|
||||
|
@ -162,6 +158,14 @@ class TwilioVirtualNumberAdapter implements AdapterInterface
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the implemented service support reception callback.
|
||||
*/
|
||||
public static function meta_support_reception(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called to send a SMS to a number.
|
||||
*
|
||||
|
@ -301,7 +305,7 @@ class TwilioVirtualNumberAdapter implements AdapterInterface
|
|||
{
|
||||
$sid = $_REQUEST['MessageSid'] ?? false;
|
||||
$status = $_REQUEST['MessageStatus'] ?? false;
|
||||
|
||||
|
||||
if (!$sid || !$status)
|
||||
{
|
||||
return false;
|
||||
|
@ -309,19 +313,38 @@ class TwilioVirtualNumberAdapter implements AdapterInterface
|
|||
|
||||
switch ($status)
|
||||
{
|
||||
case 'delivered' :
|
||||
$status = \models\Sended::STATUS_DELIVERED;
|
||||
break;
|
||||
case 'delivered' :
|
||||
$status = \models\Sended::STATUS_DELIVERED;
|
||||
break;
|
||||
|
||||
case 'failed' :
|
||||
$status = \models\Sended::STATUS_FAILED;
|
||||
break;
|
||||
case 'failed' :
|
||||
$status = \models\Sended::STATUS_FAILED;
|
||||
break;
|
||||
|
||||
default :
|
||||
$status = \models\Sended::STATUS_UNKNOWN;
|
||||
break;
|
||||
default :
|
||||
$status = \models\Sended::STATUS_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
return ['uid' => $sid, 'status' => $status];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called on reception of a sms notification.
|
||||
*
|
||||
* @return array : [
|
||||
* bool 'error' => false on success, true on error
|
||||
* ?string 'error_message' => null on success, error message else
|
||||
* array 'sms' => array [
|
||||
* string 'at' : Recepetion date format Y-m-d H:i:s,
|
||||
* string 'text' : SMS body,
|
||||
* string 'origin' : SMS sender,
|
||||
* ]
|
||||
*
|
||||
* ]
|
||||
*/
|
||||
public static function reception_callback() : array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue