twsms2 0.9.0 → 0.9.5
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.
- checksums.yaml +4 -4
- data/README.md +120 -15
- data/lib/twsms2/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5a9a3ef4feed05f9a86b7bd560496befd38d3ae
|
4
|
+
data.tar.gz: 3e7a3ea26b4277b4de7a3cecb506f61f587a1449
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27af245bfc614037b1f24fcca4cf9cc5d85107b60e3b81585181e3e131d2a15262f60e058439ec4497b004bf002fb047f0720c3807e3a115e7d527ced2d7cb06
|
7
|
+
data.tar.gz: 5dcc9589447a55a6c98f025fbdfddffddda4b60a5df9070b8cc89a07d89e05f04eef0a7dbdd88065dcb76ed30628e8a1017837bb25a771c96ea72ef78b94eee7
|
data/README.md
CHANGED
@@ -1,36 +1,141 @@
|
|
1
|
-
|
1
|
+
Twsms2 ( 2016 台灣簡訊 TwSMS API 套件 )
|
2
|
+
======================================
|
2
3
|
|
3
|
-
|
4
|
+
[](https://badge.fury.io/rb/twsms2)
|
4
5
|
|
5
|
-
|
6
|
+

|
6
7
|
|
7
|
-
|
8
|
+
此為針對 [台灣簡訊][twsms_homepage] TwSMS API 開發的專屬套件,支援 Ruby ( >= 2.1 ) 或 Ruby On Rails
|
8
9
|
|
9
|
-
|
10
|
+
您可以透過該套件來實作台灣簡訊的基本簡訊發送 與 簡訊餘額查詢 的程式
|
11
|
+
|
12
|
+
安裝方式
|
13
|
+
--------
|
14
|
+
|
15
|
+
請在您的 Ruby 或 Rails 專案裡的 Gemfile 加入以下指令
|
10
16
|
|
11
17
|
```ruby
|
12
|
-
gem 'twsms2'
|
18
|
+
gem 'twsms2', '~> 0.9.5'
|
13
19
|
```
|
14
20
|
|
15
|
-
|
21
|
+
然後執行 bundle install 更新套件組
|
16
22
|
|
17
23
|
$ bundle
|
18
24
|
|
19
|
-
|
25
|
+
或也可以直接將 twsms2 裝在系統上
|
20
26
|
|
21
27
|
$ gem install twsms2
|
22
28
|
|
23
|
-
|
29
|
+
使用方式
|
30
|
+
--------
|
31
|
+
|
32
|
+
本 API 套件,提供幾組以下方法來方便您開發簡訊相關服務
|
33
|
+
|
34
|
+
但要使用前,需要先[註冊台灣簡訊的會員][twsms_signup],否則您的程式無法存取台灣簡訊的 API 管道
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
require 'twsms2'
|
38
|
+
|
39
|
+
# Twsms2 是走 https 的方式進行系統操作
|
40
|
+
sms_client = Twsms2::Client.new(username: '台灣簡訊的會員帳號', password: '台灣簡訊的會員密碼')
|
41
|
+
```
|
42
|
+
|
43
|
+
使用範例
|
44
|
+
--------
|
45
|
+
|
46
|
+
### 系統檢查
|
47
|
+
|
48
|
+
檢查帳號是否有效、是否可以發送簡訊,有效為 true、無效則為 false
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
sms_client.account_is_available
|
52
|
+
```
|
53
|
+
|
54
|
+
----
|
55
|
+
|
56
|
+
### 發送簡訊
|
57
|
+
|
58
|
+
手機號碼可以為 8869XXYYYZZZ 或 09XXYYYZZZ 的格式 ( 以簡訊系統商建議的格式為主 )
|
59
|
+
|
60
|
+
一般方式
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
sms_client.send_message to: '手機號碼', content: "簡訊內容 #{Time.now}"
|
64
|
+
```
|
65
|
+
|
66
|
+
你可以加入 popup 參數告訴簡訊系統,發送簡訊到收訊人的手機時要直接顯示 ( 但不會儲存在手機 )
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
sms_client.send_message to: '手機號碼', content: "簡訊內容 #{Time.now}", popup: true
|
70
|
+
```
|
71
|
+
|
72
|
+
本套件發送簡訊時,預設為長簡訊發送,因此若超 SMS 短信字元長度,將會以第二封起開始計算
|
73
|
+
|
74
|
+
當然您可以關閉該設計,請加入 long 參數,並指定為 false 即可
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
sms_client.send_message to: '手機號碼', content: "簡訊內容 #{Time.now}", long: false
|
78
|
+
```
|
24
79
|
|
25
|
-
TODO: Write usage instructions here
|
26
80
|
|
27
|
-
|
81
|
+
### 發送簡訊 的 回傳結果
|
82
|
+
|
83
|
+
當你執行完成後,send_message 方法會回傳一組 hash 型態的結果
|
84
|
+
|
85
|
+
只要 access_success 的值為 true 就一定代表發送成功,若為 false 則表示過程有出現錯誤
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
{:access_success=>true, :message_id=>"217620029", :error=>nil}
|
89
|
+
```
|
90
|
+
|
91
|
+
例如:以下為帳號密碼的錯誤,error 將會記錄台灣簡訊的 error code
|
92
|
+
|
93
|
+
error code 的部分,請以 台灣簡訊 API 文件的定義為主,本套件不處理相關結果
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
{:access_success=>false, :message_id=>nil, :error=>"TWSMS:00010"}
|
97
|
+
```
|
98
|
+
|
99
|
+
----
|
100
|
+
|
101
|
+
### 查詢簡訊餘額
|
102
|
+
|
103
|
+
若你需要查詢您會員帳號的簡訊餘額,可以用以下指令處理
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
sms_client.get_balance
|
107
|
+
```
|
108
|
+
|
109
|
+
|
110
|
+
### 查詢簡訊餘額 的 回傳結果
|
111
|
+
|
112
|
+
當你執行完成後,get_balance 方法會回傳一組 hash 型態的結果
|
113
|
+
|
114
|
+
只要 access_success 的值為 true 就一定代表系統有成功取得資料
|
115
|
+
|
116
|
+
message_quota 則是簡訊餘額,代表你還剩幾封可以用,若為 0 就代表都沒有
|
117
|
+
|
118
|
+
```ruby
|
119
|
+
# 備註:簡訊商若發送過程中出現意外狀況,會晚點將簡訊額度補回您的會員帳號
|
120
|
+
{:access_success=>true, :message_quota=>77, :error=>nil}
|
121
|
+
```
|
122
|
+
|
123
|
+
若 access_success 為 false 則表示過程有出現錯誤,同時 message_quota 會為 0
|
124
|
+
|
125
|
+
```ruby
|
126
|
+
{:access_success=>false, :message_quota=>0, :error=>"TWSMS:00010"}
|
127
|
+
```
|
128
|
+
|
28
129
|
|
29
|
-
|
130
|
+
LICENSE
|
131
|
+
--------
|
30
132
|
|
31
|
-
|
133
|
+
本專案原始碼採 MIT LICENSE 授權 ( 詳見 LICENSE 檔案 )
|
32
134
|
|
33
|
-
|
135
|
+
連結分享
|
136
|
+
--------
|
34
137
|
|
35
|
-
|
138
|
+
[註冊台灣簡訊的會員][twsms_signup]、[台灣簡訊官網 與 API 文件][twsms_homepage]
|
36
139
|
|
140
|
+
[twsms_signup]: https://www.twsms.com/accjoin.php
|
141
|
+
[twsms_homepage]: https://www.twsms.com/
|
data/lib/twsms2/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twsms2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guanting Chen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|