sms_bao 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/Rakefile +1 -0
- data/lib/sms_bao.rb +90 -0
- data/lib/sms_bao/version.rb +3 -0
- data/sms_bao.gemspec +24 -0
- metadata +51 -0
data/.gitignore
ADDED
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/sms_bao.rb
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
$:.unshift(File.dirname(__FILE__))
|
|
2
|
+
require "sms_bao/version"
|
|
3
|
+
require 'digest/md5'
|
|
4
|
+
require 'open-uri'
|
|
5
|
+
|
|
6
|
+
module SmsBao
|
|
7
|
+
#send sms
|
|
8
|
+
def self.send(user_name, password, phones, content)
|
|
9
|
+
result = nil
|
|
10
|
+
password = Digest::MD5.hexdigest password
|
|
11
|
+
begin
|
|
12
|
+
open("http://www.smsbao.com/sms?u=inruby&p=#{password}&m=#{phones}&c=#{URI.escape(content)}") {|f|
|
|
13
|
+
f.each_line {|line| result = line}
|
|
14
|
+
}
|
|
15
|
+
rescue => ex
|
|
16
|
+
return ex.message
|
|
17
|
+
end
|
|
18
|
+
case result
|
|
19
|
+
when '0'
|
|
20
|
+
'success'
|
|
21
|
+
when '30'
|
|
22
|
+
'password error'
|
|
23
|
+
when '40'
|
|
24
|
+
'bad account'
|
|
25
|
+
when '41'
|
|
26
|
+
'no money'
|
|
27
|
+
when '42'
|
|
28
|
+
'account expired'
|
|
29
|
+
when '43'
|
|
30
|
+
'IP denied'
|
|
31
|
+
when '50'
|
|
32
|
+
'content sensitive'
|
|
33
|
+
when '51'
|
|
34
|
+
'bad phone number'
|
|
35
|
+
else
|
|
36
|
+
'unknown error'
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.query(user_name, password)
|
|
41
|
+
result = nil
|
|
42
|
+
password = Digest::MD5.hexdigest password
|
|
43
|
+
begin
|
|
44
|
+
open("http://www.smsbao.com/query?u=inruby&p=#{password}") {|f|
|
|
45
|
+
f.each_line {|line| result = line}
|
|
46
|
+
}
|
|
47
|
+
rescue => ex
|
|
48
|
+
return ex.message
|
|
49
|
+
end
|
|
50
|
+
result
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
=begin
|
|
55
|
+
# http://www.smsbao.com/openapi
|
|
56
|
+
|
|
57
|
+
##短信发送API
|
|
58
|
+
http://www.smsbao.com/sms?u=USERNAME&p=PASSWORD&m=PHONE&c=CONTENT
|
|
59
|
+
USERNAME:在本短信平台注册的用户名
|
|
60
|
+
PASSWORD:平台登录密码MD5后的值
|
|
61
|
+
PHONE:目标手机号码,多个手机号码用半角逗号分割
|
|
62
|
+
CONTENT:发送内容,采用UTF-8 URL ENCODE
|
|
63
|
+
|
|
64
|
+
返回 '0' 视为发送成功,其他内容为错误提示内容
|
|
65
|
+
|
|
66
|
+
##短信接收API
|
|
67
|
+
http://xxx.xxx.xxx/xxx?m=PHONE&c=CONTENT
|
|
68
|
+
http://xxx.xxx.xxx/xxx:接收短信的URL地址
|
|
69
|
+
PHONE:发送方手机号码
|
|
70
|
+
CONTENT:短信内容,采用UTF-8 URL ENCODE
|
|
71
|
+
|
|
72
|
+
返回 '0' 视为接收成功,其他内容为错误提示内容
|
|
73
|
+
|
|
74
|
+
##查询余额API
|
|
75
|
+
http://www.smsbao.com/query?u=USERNAME&p=PASSWORD
|
|
76
|
+
USERNAME:在本短信平台注册的用户名
|
|
77
|
+
PASSWORD:平台登录密码MD5后的值
|
|
78
|
+
|
|
79
|
+
第一行返回 '0' 视为发送成功,其他内容为错误提示内容
|
|
80
|
+
如果第一行返回成功,则第二行返回 '发送条数,剩余条数'
|
|
81
|
+
|
|
82
|
+
##错误代码表
|
|
83
|
+
30:密码错误
|
|
84
|
+
40:账号不存在
|
|
85
|
+
41:余额不足
|
|
86
|
+
42:帐号过期
|
|
87
|
+
43:IP地址限制
|
|
88
|
+
50:内容含有敏感词
|
|
89
|
+
51:手机号码不正确
|
|
90
|
+
=end
|
data/sms_bao.gemspec
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "sms_bao/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "sms_bao"
|
|
7
|
+
s.version = SmsBao::VERSION
|
|
8
|
+
s.authors = ["krongk"]
|
|
9
|
+
s.email = ["kenrome@gmail.com"]
|
|
10
|
+
s.homepage = "https://github.com/krongk/sms_bao"
|
|
11
|
+
s.summary = %q{A ruby api for www.smsbao.com}
|
|
12
|
+
s.description = %q{SmsBao.send(user_name, password, phones, content), SmsBao.query(user_name, password)}
|
|
13
|
+
|
|
14
|
+
s.rubyforge_project = "sms_bao"
|
|
15
|
+
|
|
16
|
+
s.files = `git ls-files`.split("\n")
|
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
19
|
+
s.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
# specify any dependencies here; for example:
|
|
22
|
+
# s.add_development_dependency "rspec"
|
|
23
|
+
# s.add_runtime_dependency "rest-client"
|
|
24
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: sms_bao
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- krongk
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2012-11-27 00:00:00.000000000 Z
|
|
13
|
+
dependencies: []
|
|
14
|
+
description: SmsBao.send(user_name, password, phones, content), SmsBao.query(user_name,
|
|
15
|
+
password)
|
|
16
|
+
email:
|
|
17
|
+
- kenrome@gmail.com
|
|
18
|
+
executables: []
|
|
19
|
+
extensions: []
|
|
20
|
+
extra_rdoc_files: []
|
|
21
|
+
files:
|
|
22
|
+
- .gitignore
|
|
23
|
+
- Rakefile
|
|
24
|
+
- lib/sms_bao.rb
|
|
25
|
+
- lib/sms_bao/version.rb
|
|
26
|
+
- sms_bao.gemspec
|
|
27
|
+
homepage: https://github.com/krongk/sms_bao
|
|
28
|
+
licenses: []
|
|
29
|
+
post_install_message:
|
|
30
|
+
rdoc_options: []
|
|
31
|
+
require_paths:
|
|
32
|
+
- lib
|
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
34
|
+
none: false
|
|
35
|
+
requirements:
|
|
36
|
+
- - ! '>='
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '0'
|
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
|
+
none: false
|
|
41
|
+
requirements:
|
|
42
|
+
- - ! '>='
|
|
43
|
+
- !ruby/object:Gem::Version
|
|
44
|
+
version: '0'
|
|
45
|
+
requirements: []
|
|
46
|
+
rubyforge_project: sms_bao
|
|
47
|
+
rubygems_version: 1.8.16
|
|
48
|
+
signing_key:
|
|
49
|
+
specification_version: 3
|
|
50
|
+
summary: A ruby api for www.smsbao.com
|
|
51
|
+
test_files: []
|