2 Commit-ok a522efe170 ... 0e2cc5ec5e

Szerző SHA1 Üzenet Dátum
  yangck 0e2cc5ec5e export sms 6 éve
  yangck 8797d8a371 add sms.js 6 éve
2 módosított fájl, 69 hozzáadás és 0 törlés
  1. 1 0
      lib/index.js
  2. 68 0
      lib/sms.js

+ 1 - 0
lib/index.js

@@ -4,6 +4,7 @@ exports.user 	 = require( './user' );
 exports.message  = require( './message' );
 exports.group 	 = require( './group' );
 exports.chatroom = require( './chatroom' );
+exports.sms = require( './sms' );
 
 
 exports.init 			  = rongrequest.init;

+ 68 - 0
lib/sms.js

@@ -0,0 +1,68 @@
+var apis = require( './apis' );
+var rongrequest = require( './rongrequest' );
+
+exports.send = function( region, mobile, templateId, format, callback ) {
+	var params = {
+		region: region,
+		mobile: mobile,
+		templateId: templateId
+	};
+
+	callback = arguments[arguments.length - 1];
+
+	rongrequest.requestSMS( apis['sms']['send'], params, format, function( err, resultText ) {
+		return callback( err, resultText );
+	} );
+};
+
+exports.sendCode = function( region, mobile, verifyId, verifyCode, templateId, format, callback ) {
+	var params;
+
+	if (arguments.length > 5) {
+		params = {
+			region: region,
+			mobile: mobile,
+			verifyId: verifyId,
+			verifyCode: verifyCode,
+			templateId: templateId
+		};
+	} else {
+		templateId = verifyId;
+		format = verifyCode;
+
+		params = {
+			region: region,
+			mobile: mobile,
+			templateId: templateId
+		};
+	}
+
+	callback = arguments[arguments.length - 1];
+
+	rongrequest.requestSMS( apis['sms']['sendCode'], params, format, function( err, resultText ) {
+		return callback( err, resultText );
+	} );
+};
+
+exports.verifyCode = function( sessionId, code, format, callback ) {
+	var params = {
+		sessionId: sessionId,
+		code: code
+  };
+
+	callback = arguments[arguments.length - 1];
+
+	rongrequest.requestSMS( apis['sms']['verifyCode'], params, format, function( err, resultText ) {
+		return callback( err, resultText );
+	} );
+};
+
+exports.getImgCode = function( appKey, callback ) {
+	var params = {
+		appkey: appKey
+	}
+
+	rongrequest.get( apis['sms']['getImgCode'], params, function( err, resultText ) {
+		return callback( err, resultText );
+	} );
+};