Coder Social home page Coder Social logo

sms-ruby's Introduction

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:

param Description
msgid SMS id given by mitake.
dstaddr Receiver phone number.
dlvtime Sms reservation time. Format is YYYYMMDDHHNNSS
donetime SMS-to-date time. Format is YYYYMMDDHHNNSS
statuscode 0 or 1 means sent successfully. If sending fails, there will be no state return.
statusstr SMS status. Please refer to statusstr table below.
StatusFlag SMS 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:

StatusFlag Description
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

statuscode shown in the table below:

statuscode Description
  •        | 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:

statusstr StatusFlag Description
DELIVRD 4 Has been served
EXPIRED 8 Timeout
DELETED 9 Reservation has been canceled
UNDELIV 6,7 Undeliverable (Phone number with errors / SMS has been disabled)
ACCEPTD 0, 1, 2, 3 SMS Processing (0 = appointment, 1,2,3 = the carriers has been served)
UNKNOWN Invalid SMS status, system error
REJECTD
SYNTAXE 5 SMS 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.

sms-ruby's People

Contributors

j094097 avatar

Watchers

Kewang avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.