使用Ruby on Rails从模板发送批量短信
使用带有Ruby on Rails的模板将批量SMS发送到一组联系人
Ruby on Rails : API文档
使用Ruby on Rails从模板发送批量短信
# net/http library is required
require 'net/http'
afilnet_class="sms";
afilnet_method="sendsmstogroupfromtemplate";
afilnet_user="user";
afilnet_password="password";
afilnet_countrycode="34";
afilnet_idgroup="1";
afilnet_idtemplate="1000";
afilnet_scheduledatetime="";
afilnet_output="";
# Create an URL request
sUrl = "https://www.afilnet.com/api/http/?class="+afilnet_class+"&method="+afilnet_method+"&user="+afilnet_user+"&password="+afilnet_password+"&countrycode="+afilnet_countrycode+"&idgroup="+afilnet_idgroup+"&idtemplate="+afilnet_idtemplate+"&scheduledatetime="+afilnet_scheduledatetime+"&output="+afilnet_output;
uri = URI(sUrl)
response = Net::HTTP.get(uri)
# net/http library is required
require 'net/http'
afilnet_class="sms";
afilnet_method="sendsmstogroupfromtemplate";
afilnet_user="user";
afilnet_password="password";
afilnet_countrycode="34";
afilnet_idgroup="1";
afilnet_idtemplate="1000";
afilnet_scheduledatetime="";
afilnet_output="";
# Create an URL request
sUrl = "https://www.afilnet.com/api/http/";
uri = URI(sUrl)
response = Net::HTTP.post_form(uri, "class" => afilnet_class, "method" => afilnet_method, "user" => afilnet_user, "password" => afilnet_password, "countrycode" => afilnet_countrycode, "idgroup" => afilnet_idgroup, "idtemplate" => afilnet_idtemplate, "scheduledatetime" => afilnet_scheduledatetime, "output" => afilnet_output)
puts response.body
# net/http library is required
require 'net/http'
afilnet_class="sms";
afilnet_method="sendsmstogroupfromtemplate";
afilnet_user="user";
afilnet_password="password";
afilnet_countrycode="34";
afilnet_idgroup="1";
afilnet_idtemplate="1000";
afilnet_scheduledatetime="";
afilnet_output="";
# Create an URL request
sUrl = "https://www.afilnet.com/api/basic/?class="+afilnet_class+"&method="+afilnet_method+"&countrycode="+afilnet_countrycode+"&idgroup="+afilnet_idgroup+"&idtemplate="+afilnet_idtemplate+"&scheduledatetime="+afilnet_scheduledatetime+"&output="+afilnet_output;
uri = URI(sUrl)
req = Net::HTTP::Get.new(uri)
req.basic_auth afilnet_user, afilnet_password
res = Net::HTTP.start(uri.hostname) {|http|
http.request(req)
}
puts res.body
# Savon library is required
require 'savon'
# We define vars
afilnet_class="sms";
afilnet_method="sendsmstogroupfromtemplate";
afilnet_user="user";
afilnet_password="password";
afilnet_countrycode="34";
afilnet_idgroup="1";
afilnet_idtemplate="1000";
afilnet_scheduledatetime="";
afilnet_output="";
# We create the client instance
client = Savon.client(wsdl: 'https://www.afilnet.com/api/soap/index.php?wsdl', ssl_verify_mode: :none)
# We call to the service
res = client.call(:call, message: {
user: afilnet_user,
password: afilnet_password,
class: afilnet_class,
method: afilnet_method,
petition: "{\"countrycode\":\""+afilnet_countrycode+"\",\"idgroup\":\""+afilnet_idgroup+"\",\"idtemplate\":\""+afilnet_idtemplate+"\",\"scheduledatetime\":\""+afilnet_scheduledatetime+"\",\"output\":\""+afilnet_output+"\"}"
})
puts res.body
参数 | 描述 | 必修/可选 |
---|---|---|
class=sms | 要求的课程:要求的课程 | 必修 |
method=sendsmstogroupfromtemplate | 请求的类方法:发出请求的类的方法 | 必修 |
user | 您的Afilnet帐户的用户和电子邮件 | 必修 |
password | 您的Afilnet帐户的密码 | 必修 |
countrycode | 国家代码 | 必修 |
idgroup | 目标组ID | 必修 |
idtemplate | 范本编号 | 必修 |
scheduledatetime | 交货日期和时间,格式为yyyy-mm-dd hh:mm:ss | 可选的 |
output | 结果的输出格式 | 可选的 |
发出请求时,您将收到以下字段:
- status
-
结果(如果status = success),您将在此处收到以下值:
- id
- count
- credits
-
destinations
- messageid
- destination
- 错误(如果status = error),在这里您将收到错误代码
下面列出了可能的错误代码
码 | 描述 |
---|---|
MISSING_USER | 不包括用户或电子邮件 |
MISSING_PASSWORD | 不包含密码 |
MISSING_CLASS | 不包括课程 |
MISSING_METHOD | 不包括方法 |
MISSING_COMPULSORY_PARAM | 不包括强制参数 |
INCORRECT_USER_PASSWORD | 用户或密码错误 |
INCORRECT_CLASS | 班级不正确 |
INCORRECT_METHOD | 方法不正确 |
NOT_ACCESS_TO_GROUP | 不允许您进入指定的组 |
NO_CREDITS | 您的余额不足 |
参数:
- class : sms
- method : sendsmstogroupfromtemplate
- user : user
- password : password
- countrycode : 34
- idgroup : 1
- idtemplate : 1000
- scheduledatetime :
- output :
请求:
https://www.afilnet.com/api/http/?class=sms&method=sendsmstogroupfromtemplate&user=user&password=password&countrycode=34&idgroup=1&idtemplate=1000&scheduledatetime=&output=