Skip to content

Commit

Permalink
coolsms initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jwchang0206 committed Sep 12, 2012
0 parents commit 6e20a1d
Show file tree
Hide file tree
Showing 8 changed files with 205 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.db
.DS_Store
.project
ssl
node_modules
.metadata
*.tmproj
*.sublime-project
dump.rdb
5 changes: 5 additions & 0 deletions Cakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{exec} = require 'child_process'

task 'watch', 'Watch CS File Changes and Compile right away', ->
exec 'coffee --watch --bare --compile --output lib/ src/', (err, stdout, stderr) ->
throw err if err
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
CoolSMS-node
=====

---

## Installation

<pre>
npm install coolsms
</pre>

or

<pre>
git clone git://github.com/InspiredJW/coolsms.git
</pre>

## Usage

```javascript
var coolsms = require('coolsms');

coolsms({
ssl: true, // true | false
user: 'username', // CoolSMS username
password: 'password', // CoolSMS password
to: '01000000000', // Recipient Phone Number
from: '01000000000', // Sender Phone Number
text: 'Hello World!' // Text to send
}, function(err, result) {
// error message in String and result information in JSON
if (err) {
console.log(err);
}
console.log(body);
});

```

##
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* CoolSMS - Node.js
* Copyright (c) 2012 InspiredJW <inspired.jw@gmail.com>
* MIT Licensed
*/
module.exports = require('./lib/coolsms');
47 changes: 47 additions & 0 deletions lib/coolsms.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "coolsms",
"description": "coolsms for Node.js",
"version": "1.0.0",
"author": "InspiredJW <inspired.jw@gmail.com>",
"keywords": ["coolsms", "sms", "text", "mobile"],
"repository": {
"type": "git",
"url": "https://github.com/InspiredJW/coolsms.git"
},
"dependencies": {
"request": "*",
"underscore": "*"
},
"main": "index",
"engines": { "node": ">= 0.6.0" }
}
39 changes: 39 additions & 0 deletions src/coolsms.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
crypto = require "crypto"
request = require "request"
_ = require "underscore"

module.exports = (input, callback) ->
options =
uri: '//api.coolsms.co.kr/sendmsg'
ssl: false
user: 'user'
password: 'password'
enc: 'md5'
to: ''
from: ''
text: ''

options = _.extend options, input

options.password = crypto
.createHash(options.enc)
.update(options.password)
.digest("hex")

request.post
uri: (if options.ssl then "https:" else "http:") + options.uri
form:
user: options.user
password: options.password
enc: options.enc
to: options.to
from: options.from
text: options.text
, (err, res, body) ->
messages = {}
lines = body.split '\n'
for line in lines
part = line.split '='
messages[part[0]] = part[1] if part[0].trim().length > 0

callback err, messages
42 changes: 42 additions & 0 deletions src/coolsms.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6e20a1d

Please sign in to comment.