Grails 和短信插件
Grails & SMS plugin
有没有可以轻松与Grails集成的短信插件推荐?
我正在构建一个管理系统,通过短信向客户发送 Y/N 确认信息。
SMS 服务的成本和交付质量取决于您要将 SMS 发送到哪些国家/地区,但是(在更改为瑞典供应商之前)我们使用了国际供应商 Clickatell,结果还不错。
您不需要为此使用 Grails 插件,只需将 HTTPBuilder(例如通过包含 Grails REST 插件)与 Grails 结合使用,根据他们的文档调用 Clickatell API。
这是一些旧的示例代码(如果 API 已更改,则可能无法正常工作):
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.EncoderRegistry
import static groovyx.net.http.Method.POST
import static groovyx.net.http.ContentType.URLENC
import static groovyx.net.http.ContentType.TEXT
def http = new HTTPBuilder(host)
http.contentType = TEXT
EncoderRegistry encoders = new EncoderRegistry();
encoders.setCharset('ISO-8859-1')
http.setEncoderRegistry(encoders)
http.request(POST) {
uri.path = 'http/sendmsg'
requestContentType = URLENC
body = [api_id: '1234567', user: 'john', password: 'doe', from: 'Company', to: NUMBER, text: 'Hello world', concat: '3', callback: '2', deliv_ack: '1']
response.success = { resp, reader ->
def msg = reader.text
if (msg.substring(0, 2) == 'ID') {
} else if (msg.substring(0, 3) == 'ERR') {
} else {
}
}
response.failure = { resp ->
}
}
有没有可以轻松与Grails集成的短信插件推荐?
我正在构建一个管理系统,通过短信向客户发送 Y/N 确认信息。
SMS 服务的成本和交付质量取决于您要将 SMS 发送到哪些国家/地区,但是(在更改为瑞典供应商之前)我们使用了国际供应商 Clickatell,结果还不错。
您不需要为此使用 Grails 插件,只需将 HTTPBuilder(例如通过包含 Grails REST 插件)与 Grails 结合使用,根据他们的文档调用 Clickatell API。
这是一些旧的示例代码(如果 API 已更改,则可能无法正常工作):
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.EncoderRegistry
import static groovyx.net.http.Method.POST
import static groovyx.net.http.ContentType.URLENC
import static groovyx.net.http.ContentType.TEXT
def http = new HTTPBuilder(host)
http.contentType = TEXT
EncoderRegistry encoders = new EncoderRegistry();
encoders.setCharset('ISO-8859-1')
http.setEncoderRegistry(encoders)
http.request(POST) {
uri.path = 'http/sendmsg'
requestContentType = URLENC
body = [api_id: '1234567', user: 'john', password: 'doe', from: 'Company', to: NUMBER, text: 'Hello world', concat: '3', callback: '2', deliv_ack: '1']
response.success = { resp, reader ->
def msg = reader.text
if (msg.substring(0, 2) == 'ID') {
} else if (msg.substring(0, 3) == 'ERR') {
} else {
}
}
response.failure = { resp ->
}
}