Skip to content

Repository files navigation

Mitake

Taiwan SMS Provider Mitake API

Installation

Add this line to your application's Gemfile:

gem'mitake'

And then execute:

$ bundle

Or install it yourself as:

$ gem install mitake

Usage

Initialize mitake api:

mitake = Mitake::API.new(username: YOUR_USERNAME, password: YOUR_PASSWORD)

Get Account Balance:

mitake.get_balance

Send Message:

mitake.send_sms(numbers: DEST_MOBILE,message: YOUR_MESSAGE)mitake.send_sms(numbers: [DEST_MOBILE1,DEST_MOBILE2,DEST_MOBILE3],message: YOUR_MESSAGE)#[{"msgid"=>"0939137671", "statuscode"=>"1"}, {"msgid"=>"0939138467", "statuscode"=>"1"}, {"AccountPoint"=>"96"}]# or#{"statuscode"=>"e", "Error"=>"帳號、密碼錯誤"}mitake.send_long_sms(number: DEST_MOBILE,message: YOUR_MESSAGE)#for message more then 70 characters

Send Message with callback:

mitake.send_sms(numbers: DEST_MOBILE,message: YOUR_MESSAGE,response_callback_url: YOUR_CALLBACK_URL)mitake.send_sms(numbers: [DEST_MOBILE1,DEST_MOBILE2,DEST_MOBILE3],message: YOUR_MESSAGE,response_callback_url: YOUR_CALLBACK_URL)mitake.send_long_sms(number: DEST_MOBILE,message: YOUR_MESSAGE,response_callback_url: YOUR_CALLBACK_URL)#will get YOUR_CALLBACK_URL?msgid=xxx&dstaddr=xxx&dlvtime=xxx&donetime=xxx&statusstr=xxx&statuscode=xxx&StatusFlag=xxx#then your response must be magicid=sms_gateway_rpack[LF]msgid=MsgId[LF] #[LF] means \n

CALLBACK params shown in the table below:

paramDescription
msgidSMS id given by mitake.
dstaddrReceiver phone number.
dlvtimeSms reservation time. Format is YYYYMMDDHHNNSS
donetimeSMS-to-date time. Format is YYYYMMDDHHNNSS
statuscode0 or 1 means sent successfully. If sending fails, there will be no state return.
statusstrSMS status. Please refer to statusstr table below.
StatusFlagSMS status. Please refer to StatusFlag table below.

Get Message Status:

mitake.get_message(msgid: MESSAGE_ID)mitake.get_message(msgid: MESSAGE_ID1,MESSAGE_ID2,MESSAGE_ID3)#{"msgid"=>"0939137671", "statuscode"=>"4", "statustime"=>"20160808153248"}

StatusFlag shown in the table below:

StatusFlagDescription
0Reservation
1Has been served
2Has been served
3Has been served
4Has been served
5Content with errors
6Phone number with errors
7Has been disabled
8Timeout
9Reservation has been canceled

statuscode shown in the table below:

statuscodeDescription
  •  | System error, please contact Mitake. |
    

a | SMS sending is temporarily out of service. Please try again later. | b | SMS sending is temporarily out of service. Please try again later. | c | Please enter your account. | d | Please enter your password. | e | Account and password error. | f | Account has expired. | h | Account has disabled. | k | Invalid connection address. | m | You must change your password. | n | Password has expired. | p | Permission denied. | r | System out of service, please try again later. | s | Accounting treatment failure. | t | SMS has expired. | u | SMS content can not be blank. | v | Invalid phone number. | 0 | Reservation | 1 | Has been served | 2 | Has been served | 3 | Has been served | 4 | Has been served | 5 | Content with errors | 6 | Phone number with errors | 7 | Has been disabled | 8 | Timeout | 9 | Reservation has been canceled |

statusstr shown in the table below:

statusstrStatusFlagDescription
DELIVRD4Has been served
EXPIRED8Timeout
DELETED9Reservation has been canceled
UNDELIV6,7Undeliverable (Phone number with errors / SMS has been disabled)
ACCEPTD0, 1, 2, 3SMS Processing (0 = appointment, 1,2,3 = the carriers has been served)
UNKNOWNInvalid SMS status, system error
REJECTD
SYNTAXE5SMS content error

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/j094097/mitake. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

About

Mitake SMS library for Ruby (Unofficial)

Topics

Resources

Code of conduct

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages