Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f94ca2e
commit 222a3cb
Showing
9 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,22 @@ | |||
class ApiController < ApplicationController | |||
|
|||
def smsnumbers | |||
@did = "" | |||
|
|||
@numbers = Voicememo.find(:all, :select => "DISTINCT(callerid)") | |||
|
|||
@numbers.each do |number| | |||
if isNumeric(number.callerid) | |||
@did << number.callerid + "," | |||
end | |||
end | |||
|
|||
@did = @did.chop #remove last comma from @did string | |||
|
|||
respond_to do |format| | |||
format.xml {} | |||
format.json {} | |||
end | |||
end | |||
|
|||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,3 +1,6 @@ | |||
class ApplicationController < ActionController::Base | class ApplicationController < ActionController::Base | ||
# protect_from_forgery | # protect_from_forgery | ||
def isNumeric(s) | |||
Float(s) != nil rescue false | |||
end | |||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,2 @@ | |||
module ApiHelper | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,4 @@ | |||
{"user":{ | |||
"phones":"<%=@did %>" | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,8 @@ | |||
require 'test_helper' | |||
|
|||
class ApiControllerTest < ActionController::TestCase | |||
# Replace this with your real tests. | |||
test "the truth" do | |||
assert true | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,4 @@ | |||
require 'test_helper' | |||
|
|||
class ApiHelperTest < ActionView::TestCase | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,27 @@ | |||
#---------- | |||
# Group sms | |||
#---------- | |||
require 'open-uri' | |||
require 'json' | |||
|
|||
url = 'http://voiceboard.heroku.com/api/smsnumbers.json' | |||
mymessage = $currentCall.initialText | |||
|
|||
#JSON data to a Ruby hash | |||
data = JSON.parse(open(url).read) | |||
|
|||
#Get the relevant data | |||
phones = data["user"]["phones"] | |||
|
|||
#start the blasting | |||
numbers = phones.split(",") | |||
numbers.each do |number| | |||
|
|||
message(mymessage, { | |||
:to => number, | |||
:network => "SMS", | |||
:callerID => $currentCall.calledID.to_s | |||
}) | |||
end | |||
|
|||
|