Skip to content

Commit

Permalink
Extensions: twilio improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
abolabo committed Apr 5, 2018
1 parent 85886ab commit aadda3c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
Expand Up @@ -39,6 +39,7 @@ public function test()
$AuthToken = $cfg['default_twilio_token'];

$sender = new \Twilio\Rest\Client( $AccountSid, $AuthToken );
$to = preg_replace('/[^0-9\+]/','',$this->request->get['to']);

if ( $this->config->get( 'default_twilio_test' ) ) {
//sandbox number without errors from api
Expand All @@ -50,7 +51,7 @@ public function test()
$error_message = '';
try {
$sender->messages->create(
"+15005550006",
$to,
array('from' => $from,
'body' => 'test message')
);
Expand Down
Expand Up @@ -29,6 +29,11 @@
<value>
<![CDATA[Sender (Twilio) Phone: <span class="help">Phone number of sender in international format (ex. +14158675309)</span>]]></value>
</definition>
<definition>
<key>default_twilio_send_to</key>
<value>
<![CDATA[Send test SMS to: ]]></value>
</definition>
<definition>
<key>default_twilio_test_0</key>
<value><![CDATA[No]]></value>
Expand Down
@@ -1,12 +1,27 @@
<div class="col-sm-12">
<div class="row col-sm-2 mt5">
<?php
echo $this->html->buildElement( array(
'type' => 'button',
'name' => 'test_connection',
'title' => $text_test,
'text' => $text_test,
'style' => 'btn btn-info'
)); ?>

echo $this->language->get('default_twilio_send_to'); ?>
</div><div class="row col-sm-3 input-group afield">
<?php
echo $this->html->buildElement( array(
'type' => 'input',
'name' => 'to',
'value' => '+15005550006',
'style' => 'col-sm-2'
));
?><span class="input-group-btn">
<?php
echo $this->html->buildElement( array(
'type' => 'button',
'name' => 'test_connection',
'title' => $text_test,
'text' => $text_test,
'style' => 'btn btn-info'
)); ?>
</span>
</div>
</div>
<script type="text/javascript">
<?php if ( $this->config->get('default_twilio_test')){ ?>
Expand All @@ -23,6 +38,7 @@ echo $this->html->buildElement( array(
url: '<?php echo $this->html->getSecureUrl('r/extension/default_twilio/test'); ?>',
type: 'GET',
dataType: 'json',
data: {'to': $('#to').val()},
beforeSend: function() {
$('#test_connection').button('loading');
},
Expand Down
4 changes: 0 additions & 4 deletions public_html/extensions/default_twilio/config.xml
Expand Up @@ -22,10 +22,6 @@
<type required="true">input</type>
<default_value></default_value>
</item>
<item id="default_twilio_sender_phone">
<type required="true">input</type>
<default_value></default_value>
</item>
<item id="default_twilio_test">
<type>selectbox</type>
<variants>
Expand Down

0 comments on commit aadda3c

Please sign in to comment.