tatango-sms 0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ === 0.1 / 2008-10-17
2
+
3
+ * 1st write
4
+ * send messages in one line
5
+ * receive messages with a block
6
+
7
+
@@ -0,0 +1,7 @@
1
+ History.txt
2
+ README.txt
3
+ Manifest.txt
4
+ lib/tatango_sms.rb
5
+ lib/tatango_sms/mo.rb
6
+ lib/tatango_sms/mt.rb
7
+ test/test_tatango_sms.rb
@@ -0,0 +1,52 @@
1
+ = TatangoSMS
2
+
3
+ * http://tatango.com/developers
4
+
5
+ == Description
6
+
7
+ The Tatango Messaging Gateway provides a way for you to utilize our streamlined messaging pipeline to send out SMS messages to your users. SMS messages are advertisement-supported, so we can provide this service at zero cost to the developer.
8
+
9
+ == Sign-up
10
+
11
+ In order to use the Tatango SMS Gateway, you will need to sign up for a gateway key. You can sign up at http://tatango.com/developers/gateway.
12
+
13
+ == Install
14
+
15
+ gem install tatango-sms
16
+
17
+ == Requirements
18
+
19
+ TatangoSMS::MO requires +mongrel+ and +activesupport+. Neither are listed as a gem dependency because TatangoSMS::MT does not require them.
20
+
21
+ TatangoSMS::MT requires <tt>digest/md5</tt>, <tt>net/http</tt>, and +uri+ from ruby core.
22
+
23
+ == Documentation
24
+
25
+ TatangoSMS::MT:: for mobile-terminated support
26
+ TatangoSMS::MO:: for mobile-oriented support
27
+
28
+ more documentation can be found at: http://tatango.com/developers/gateway/docs
29
+
30
+ == Support
31
+
32
+ Have questions? You can usually find the Tatango engineering team at ##tatango on Freenode.
33
+
34
+ More information here: http://tatango.com/developers/connect
35
+
36
+ == Example
37
+
38
+ require 'rubygems'
39
+ require 'tatango_sms/mt'
40
+ require 'tatango_sms/mo'
41
+
42
+ # setup a mobile terminated object with our Tatango SMS Gateway key and password
43
+ mt = TatangoSMS::MT.new('key', 'password')
44
+
45
+ # run a server on port 3333 to accept incoming messages from Tatango
46
+ server = TatangoSMS:MO.server('0.0.0.0', '3333')
47
+ TatangoSMS::MO.receive(server, '/') do |phone_number, content|
48
+ # send the reversed message back
49
+ mt.send(phone_number, content.reverse)
50
+ end
51
+
52
+ server.run.join
@@ -0,0 +1,36 @@
1
+ # This file is part of TatangoSMS.
2
+ #
3
+ # TatangoSMS is a simple library to facilitate the use of the Tatango
4
+ # Messaging Gateway. The Tatango Messaging Gateway provides a way for you to utilize our
5
+ # streamlined messaging pipeline to send out SMS messages to your users.
6
+ # SMS messages are advertisement-supported, so we can provide this
7
+ # service at zero cost to the developer.
8
+ #
9
+ # More information can be found at http://tatango.com/developers/gateway
10
+ #
11
+ # Copyright (c) 2008, Tatango Inc.
12
+ # All rights reserved.
13
+ #
14
+ #
15
+ # TatangoSMS is free software: you can redistribute it and/or modify
16
+ # it under the terms of the GNU Lesser Public License as published by
17
+ # the Free Software Foundation, either version 3 of the License, or
18
+ # (at your option) any later version.
19
+ #
20
+ # TatangoSMS is distributed in the hope that it will be useful,
21
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ # GNU Lesser Public License for more details.
24
+ #
25
+ # You should have received a copy of the GNU Lesser Public License
26
+ # along with TatangoSMS. If not, see <http://www.gnu.org/licenses/>.
27
+
28
+
29
+
30
+ require 'tatango_sms/mo'
31
+ require 'tatango_sms/mt'
32
+
33
+
34
+ module TatangoSMS
35
+ VERSION = '0.1'
36
+ end
@@ -0,0 +1,99 @@
1
+ # This file is part of TatangoSMS.
2
+ #
3
+ # TatangoSMS is a simple library to facilitate the use of the Tatango
4
+ # Messaging Gateway. The Tatango Messaging Gateway provides a way for you to utilize our
5
+ # streamlined messaging pipeline to send out SMS messages to your users.
6
+ # SMS messages are advertisement-supported, so we can provide this
7
+ # service at zero cost to the developer.
8
+ #
9
+ # More information can be found at http://tatango.com/developers/gateway
10
+ #
11
+ # Copyright (c) 2008, Tatango Inc.
12
+ # All rights reserved.
13
+ #
14
+ #
15
+ # TatangoSMS is free software: you can redistribute it and/or modify
16
+ # it under the terms of the GNU Lesser Public License as published by
17
+ # the Free Software Foundation, either version 3 of the License, or
18
+ # (at your option) any later version.
19
+ #
20
+ # TatangoSMS is distributed in the hope that it will be useful,
21
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ # GNU Lesser Public License for more details.
24
+ #
25
+ # You should have received a copy of the GNU Lesser Public License
26
+ # along with TatangoSMS. If not, see <http://www.gnu.org/licenses/>.
27
+
28
+
29
+ require 'rubygems'
30
+ require 'mongrel'
31
+ require 'activesupport' # for Hash.from_xml
32
+
33
+
34
+ module TatangoSMS
35
+
36
+ # TatangoSMS::MO makes it easy to receive messages from the Tatango SMS Gateway
37
+ #
38
+ # Example:
39
+ # require 'tatango_sms/mo'
40
+ # server = TatangoSMS::MO.server('0.0.0.0', '3333')
41
+ # TatangoSMS::MO.receive(server, '/') do |phone_number, content|
42
+ # # parse content and do something
43
+ # # maybe even send a message back with TatangoSMS::MT.send(...)
44
+ # end
45
+ # server.run.join
46
+ class MO
47
+ class << self
48
+
49
+ # setup a new mongrel server to accept MOs
50
+ #
51
+ # returns a Mongrel::HttpServer
52
+ #
53
+ # Examples:
54
+ # server = Mongrel::MO.server('0.0.0.0', '3333')
55
+ # # see MO::receive for how to register a block of code to receive messages
56
+ # server.run # run the server
57
+ # server.acceptor.join # the acceptor thread can be found here
58
+ def server(*args)
59
+ Mongrel::HttpServer.new(*args)
60
+ end
61
+
62
+ # register a block of code to receive messages
63
+ #
64
+ # expects a Mongrel::HttpServer. use MO.server or just use one you already have?
65
+ #
66
+ # NOTE: +content+ will be exactly what the user entered in their cell phone.
67
+ # if they used your keyword, it will also be in +content+
68
+ #
69
+ # Example:
70
+ # TatangoSMS::MO.receive(server, '/') do |phone_number, content|
71
+ # puts "message from #{phone_number} was #{content}"
72
+ # end
73
+ def receive(server, path = '/', &blk)
74
+ server.register(path, Handler.new(&blk))
75
+ end
76
+ end
77
+
78
+ class Handler < Mongrel::HttpHandler # :nodoc:
79
+ def initialize(&blk)
80
+ @processor = blk
81
+ end
82
+
83
+ def process(request, response)
84
+
85
+ params = Hash.from_xml(request.body.read)
86
+ phone_number = params['message']['sender']
87
+ content = params['message']['content']
88
+
89
+ # puts "Processing request from: #{request.params['REMOTE_ADDR']} phone: #{phone_number}"
90
+
91
+ @processor.call(phone_number, content)
92
+
93
+ response.start(202) do |head,out|
94
+ head["Content-Type"] = 'text/plain'
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,77 @@
1
+ # This file is part of TatangoSMS.
2
+ #
3
+ # TatangoSMS is a simple library to facilitate the use of the Tatango
4
+ # Messaging Gateway. The Tatango Messaging Gateway provides a way for you to utilize our
5
+ # streamlined messaging pipeline to send out SMS messages to your users.
6
+ # SMS messages are advertisement-supported, so we can provide this
7
+ # service at zero cost to the developer.
8
+ #
9
+ # More information can be found at http://tatango.com/developers/gateway
10
+ #
11
+ # Copyright (c) 2008, Tatango Inc.
12
+ # All rights reserved.
13
+ #
14
+ #
15
+ # TatangoSMS is free software: you can redistribute it and/or modify
16
+ # it under the terms of the GNU Lesser Public License as published by
17
+ # the Free Software Foundation, either version 3 of the License, or
18
+ # (at your option) any later version.
19
+ #
20
+ # TatangoSMS is distributed in the hope that it will be useful,
21
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ # GNU Lesser Public License for more details.
24
+ #
25
+ # You should have received a copy of the GNU Lesser Public License
26
+ # along with TatangoSMS. If not, see <http://www.gnu.org/licenses/>.
27
+
28
+
29
+ require 'digest/md5'
30
+ require 'net/http'
31
+ require 'uri'
32
+
33
+ module TatangoSMS
34
+
35
+ # TatangoSMS::MT makes it easy to send a message through the Tatango SMS Gateway
36
+ #
37
+ # Examples:
38
+ # require 'tatango_sms/mt'
39
+ # TatangoSMS::MT.send('tatangosmsgatewayKEY', 'password', '9998887777', 'A message')
40
+ # # or
41
+ # mt = TatangoSMS::MT.new 'tatangosmsgatewayKEY', 'password'
42
+ # response = mt.send '9998887777', 'Another silly message'
43
+ class MT
44
+
45
+ @@gateway_url = 'http://gateway.tatango.com/messages'
46
+
47
+ class << self
48
+ # see MT#send
49
+ def send(key, password, phone_number, message)
50
+ new(key, password).send(phone_number, message)
51
+ end
52
+
53
+ def url=(url) # :nodoc:
54
+ @@gateway_url = url
55
+ end
56
+ end
57
+
58
+ # create an MT instance to avoid repetition of key and password
59
+ def initialize(key, password)
60
+ @gateway_key, @gateway_password = key, password
61
+ end
62
+
63
+ # send a +message+ to +phone_number+
64
+ #
65
+ # returns a Net::HTTP response
66
+ def send(phone_number, message)
67
+ Net::HTTP.post_form(
68
+ URI.parse(@@gateway_url), {
69
+ 'key' => @gateway_key,
70
+ 'recipient' => phone_number,
71
+ 'message' => message,
72
+ 'hash' => Digest::MD5.hexdigest(@gateway_password + message)
73
+ }
74
+ )
75
+ end
76
+ end
77
+ end
@@ -0,0 +1 @@
1
+ # Sorry, no tests written yet
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tatango-sms
3
+ version: !ruby/object:Gem::Version
4
+ version: "0.1"
5
+ platform: ruby
6
+ authors:
7
+ - Amiel Martin
8
+ - Adrian Pike
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2008-10-20 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: hoe
18
+ type: :development
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 1.8.0
25
+ version:
26
+ description: The Tatango Messaging Gateway provides a way for you to utilize our streamlined messaging pipeline to send out SMS messages to your users. SMS messages are advertisement-supported, so we can provide this service at zero cost to the developer.
27
+ email:
28
+ - amiel@tatango.com
29
+ - apike@tatango.com
30
+ executables: []
31
+
32
+ extensions: []
33
+
34
+ extra_rdoc_files:
35
+ - History.txt
36
+ - README.txt
37
+ - Manifest.txt
38
+ files:
39
+ - History.txt
40
+ - README.txt
41
+ - Manifest.txt
42
+ - lib/tatango_sms.rb
43
+ - lib/tatango_sms/mo.rb
44
+ - lib/tatango_sms/mt.rb
45
+ - test/test_tatango_sms.rb
46
+ has_rdoc: true
47
+ homepage: http://tatango.com/developers/gateway
48
+ post_install_message:
49
+ rdoc_options:
50
+ - --main
51
+ - README.txt
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ version:
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: "0"
65
+ version:
66
+ requirements: []
67
+
68
+ rubyforge_project: tatango-sms
69
+ rubygems_version: 1.2.0
70
+ signing_key:
71
+ specification_version: 2
72
+ summary: The Tatango Messaging Gateway provides a way for you to utilize our streamlined messaging pipeline to send out SMS messages to your users
73
+ test_files:
74
+ - test/test_tatango_sms.rb