Skip to content

Instantly share code, notes, and snippets.

@mavroudis
Last active November 23, 2016 18:58
Show Gist options
  • Save mavroudis/6024310 to your computer and use it in GitHub Desktop.
Save mavroudis/6024310 to your computer and use it in GitHub Desktop.
HTML SIPmly API Example Reference: http://www.sipmly.com/api/sms/
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Send SMS</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<form>
<fieldset>
<legend>Send SMS</legend>
<div class="input-prepend">
<span class="add-on"><i class="icon-user"></i></span>
<input id="to" type="text" data-provide="typeahead" placeholder="Enter phone number...">
</div>
<br/>
<div class="input-prepend">
<span class="add-on"><i class="icon-comment"></i></span>
<textarea rows="4" id="message" placeholder="Enter a short message up to 160 characters." maxlength="160"></textarea>
</div>
<br/>
<div id="submit" type="submit" class="btn btn-large btn-primary">Send</div>
</fieldset>
</form>
</div> <!-- /container -->
<div class="modal hide fade" id="mnotice">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3 id="hnotice"></h3>
</div>
<div class="modal-body">
<p id="bnotice"></p>
</div>
<div class="modal-footer">
<button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>
<script src="http://code.jquery.com/jquery.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<script>(function(e,t){"use strict";var n;var r;var i=function(){var t=e.location;var i=decodeURIComponent(t.search);var s=decodeURIComponent(t.hash);var o,u,a;var f={};i=i.replace("?","").split("&");s=s.replace("#","").split("&");for(o=0,u=i.length;o<u;o++){a=i[o].split("=");if(a[0]){f[a[0]]=a[1]}}for(o=0,u=s.length;o<u;o++){a=s[o].split("=");if(a[0]){f[a[0]]=a[1]}}n=t.href;r=f;return f};r=i();t.getUrlVars=function(){var t=e.location.href;var s;if(t===n){s=r}else{s=i()}return s};t.getUrlVar=function(e){return t.getUrlVars()[e]}})(this,jQuery)</script>
<script>
$(function() {
/* Start account settings */
var api = '0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a';
var from = '8005551212';
/* End account settings */
$("#to").val($.getUrlVars()["to"]);
$("#submit").click(function() {
var error = [];
var to = $("#to").val().replace(/[^0-9]/g, '');
var message = $("#message").val();
if ((to.length < 10) || (to.length > 11) || ((to.length == 11) && (to.charAt(0) != '1'))) {
error.push("Please enter a valid phone number.");
}
if (message.length === 0) {
error.push("Please enter a short message up to 160 characters.");
}
if (error.length === 0) {
$.ajax({type: "GET", url: "http://api.sipmly.com/sms.pl",
data: { h: api, f: from, t: to, m: encodeURIComponent(message) }
});
$('#hnotice').html("Message Sent");
$('#bnotice').html(message);
$("form")[0].reset();
} else {
$('#hnotice').html("Form Error");
$('#bnotice').html(error.join('<br/>'));
}
$('#mnotice').modal('show');
});
});
</script>
</body>
</html>
@mavroudis
Copy link
Author

Use:

sms.html

or

sms.html?to=2015551212

@drizzlewise
Copy link

can it be used for international numbers? and can the there be a text ID so that the recipient can have an idea who sent the text? as a matter of fact hw do i mk use of the code thanks. am new to codes i really want to learn, i hope am not bothering you thankx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment