diff --git a/README.md b/README.md index e9b50e9..31898a9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ ### TextBelt -TextBelt (http://textbelt.com) is an outgoing SMS API that uses carrier-specific gateways to deliver your text messages for free, and without ads. The service is fairly reliable and has sent over 100,000 texts. +TextBelt (http://textbelt.com) is a REST API that sends outgoing SMS. It is available as a public service or as an internally self-hosted server. + +Textbelt uses carrier-specific gateways to deliver your text messages for free, and without ads. The service is fairly reliable and has sent over 1 million texts. Send a text with a simple POST request: @@ -18,6 +20,8 @@ Sample success: {"success":true} ``` +Note that success means that the message was sent to Textbelt's list of providers. We can't guarantee delivery on your network. + Sample failure: ``` @@ -74,6 +78,8 @@ Canadian and international support may not be complete. Refer to the list of su ### Notes and Limitations + * Some carriers are picky about which messages they deliver. A "success" response from Textbelt means that your message was given to the carrier. + * IP addresses are limited to 75 texts per day. Phone numbers are limited to 3 texts every 3 minutes. If you need increased limits, please contact admin@textbelt.com. * Some carriers may deliver text messages from "txt@textbelt.com" diff --git a/lib/text.js b/lib/text.js index c71df37..dd6a462 100644 --- a/lib/text.js +++ b/lib/text.js @@ -4,6 +4,7 @@ var providers = require('./providers.js') , spawn = require('child_process').spawn; var debugEnabled = false; +var fromAddress = 'foo@bar.com'; //---------------------------------------------------------------- /* @@ -56,7 +57,7 @@ function sendText(phone, message, region, cb) { _.each(providers_list, function(provider) { var email = provider.replace('%s', phone); email = 'Subject: Text\r\n\r\n' + email; - var child = spawn('sendmail', ['-f', 'txt2@textbelt.com', email]); + var child = spawn('sendmail', ['-f', fromAddress, email]); child.stdout.on('data', output); child.stderr.on('data', output); child.on('error', function(data) { diff --git a/server/app.js b/server/app.js index fc85413..6d39e5d 100644 --- a/server/app.js +++ b/server/app.js @@ -16,7 +16,14 @@ app.set('view engine', 'jade'); app.use(express.cookieParser()); app.use(express.static(__dirname + '/public')); -app.use(express.bodyParser()); +app.use(express.json()); +app.use(express.urlencoded()); +app.use(function(req, res, next) { + // Enable CORS so sites can use the API directly in JS. + res.header('Access-Control-Allow-Origin', '*'); + res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept'); + next(); +}); // Enable log messages when sending texts. text.debug(true); diff --git a/server/views/index.html b/server/views/index.html index 0993803..444a6c8 100644 --- a/server/views/index.html +++ b/server/views/index.html @@ -35,7 +35,13 @@ body { -

TextBelt is an outgoing SMS API that uses carrier-specific gateways to deliver your text messages for free, and without ads. The service is fairly reliable and has sent over 100,000 texts.

+

+TextBelt is a REST API that sends outgoing SMS. It is available as a public service or as an internally self-hosted server. +

+ +

+Textbelt uses carrier-specific gateways to deliver your text messages for free, and without ads. The service is fairly reliable and has sent over 1 million texts. +

Send a text with a simple POST request:

@@ -53,6 +59,8 @@ body {
{"success":true}
 
+

Note that success means that the message was sent to Textbelt's list of providers. We can't guarantee delivery on your network.

+

Sample failure:

{"success":false,"message":"Exceeded quota for this phone number."}
@@ -79,6 +87,7 @@ Canadian and international support may not be complete.  Please refer to the lis
 

Notes and Limitations