Skip Navigation Links.
展开 最小化

SpreadWebServcie.SendSMS Method

创建一个SMS活动和发送.

参数

参数 类型 描述 事务性 营销性
loginEmail String Spread账号的登录邮箱 必填 必填
APIKey String Spread账号的API Key(参见:如何从Spread平台获取API账号信息 必填 必填
SMSContent String SMS的发送内容. 必填 必填
sender String SMS的发送者。
保持此参数为空,除非您的账号配置了发送者。
选填 选填
schedule DateTime SMS活动的计划发送时间。过去的时间会立刻发送。
格式:yyyy-MM-ddTHH:mm:ss,时区:UTC +08:00。
营销性SMS会按照此时间发送,事务性SMS会立刻发送。
必填 必填
campaignStatus CampaignStatus SMS活动的状态. (CampaignStatus.Waiting,CampaignStatus.Draft) 必填 必填
phoneSubscribers String[] 联系人/订阅者的号码.
事务性SMS填写该参数值,否则为空。
必填
category String[] 这个SMS活动的目标联系人名单的名称.
营销性SMS填写该参数值,否则为空。
必填

参数phoneSubscriberscategory只填写其中一个,另一个留空。

返回结果

IntegerException。如果成功,则返回 campaign Id(大于0的数字),否则返回异常(Exception)或者小于等于0的数字。

请在下列表格中找到详细的返回信息:

状态/场景

返回类型

返回信息

成功发送SMS 或 成功创建 SMS 活动。

Integer

Campaign Id,这个值是数字且大于0。

发送SMS失败。

Integer

返回小于等于0的数字。

使用错误的账号或者API Key。

Exception

抛出一个异常含有信息 'Spreader Email and Password not match!'。

使用的账号过期了。

Exception

抛出一个异常含有信息 'This user has expired!'。

账号内的设置的Sender不包含该Sender,请修改。

Exception

抛出一个异常含有信息 'Sender format error! [Sender ID]'。

该账号未设置短信供应商,请联系管理员进行设置。

Exception

抛出一个异常含有信息 'Contact us at spread@reasonables.com to get SMS service.'。

该账号未设置短信供应商或者设置信息错误,请联系管理员进行确认。

Exception

抛出一个异常含有信息 'Configured vendor is error!'。

该账号没有短信的发送量,需充值再使用。

Exception

抛出一个异常含有信息 'No SMS message credit!'。

创建SMS活动失败。

Exception

抛出一个异常含有信息 'Create SMS campaign fail!'。

其他错误情况,比如超时。

Exception

抛出一个异常含有错误信息。

例子

string loginEmail = "Spread@reasonables.com";
string APIKey = "TEST0000-TEST-0000-TEST-0000TEST0000";
string SMScontent = "Test";
string senderNumber = "85212345678";
string[] phoneSubscribers = {"85265206520", "85265216521"};
string[] categorys  = {"myTestList1", "myTestList2", "myTestList3"};
SpreadAPI.SpreadWebService MySpread = new SpreadAPI.SpreadWebService();
int smsCampaignID = MySpread.SendSMS(loginEmail, APIKey, SMScontent, senderNumber, DateTime.Now, SpreadAPI.CampaignStatus.Waiting, phoneSubscribers, categorys);
Dim MySpread As New SpreadWS.SpreadWebService()
Dim loginEmail As String = "Spread@reasonables.com"
Dim APIKey As String = "TEST0000-TEST-0000-TEST-0000TEST0000"
Dim SMScontent As String = "Test"
Dim senderNumber As String = "85212345678"
Dim phoneSubscribers() As String = {"85265206520", "85265216521"}
Dim categorys() As String = {"myTestList1", "myTestList2", "myTestList3"}
Dim smsCampaignID As Integer = MySpread.SendSMS(loginEmail, APIKey, SMScontent, senderNumber, Now, SpreadWS.CampaignStatus.Waiting, phoneSubscribers, categorys)
//using curl 
//sudo apt-get install php-curl or sudo apt-get install php5-curl
 
//extract data from the post
//set POST variables
$url = 'http://service1.rspread.com/service.asmx/SendSMS';
//$schedule = time();
$phoneSubscribers = array('8613800138000'); //array of string
$category = array();
 
$fields = array(
    'loginEmail'        =>  urlencode('spread@reasonables.com'),
    'APIKey'            =>  urlencode('****API KEY****'),
    'SMSContent'        =>  urlencode('Download NoClone 4 at http://noclone.net now!'),
    'sender'            =>  urlencode('Hiruscar'),  // if you dont have sender id please set to 'sender' => urlencode(''),
    'schedule'          =>  urlencode("2022-12-20T14:50:50"),
    //'schedule'        =>  $schedule,
    'campaignStatus'    =>  urlencode('4'), // waiting and will send at schedule
    'phoneSubscribers'  =>  urldecode(http_build_query($phoneSubscribers));
    //'category'        =>  $category,
    'category'          =>  urldecode(http_build_query($category));
);
 
$fields_string='';
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
 
//open connection
$ch = curl_init();
 
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
 
//execute post
$result = curl_exec($ch);
 
//close connection
curl_close($ch);
 
 
//using soapclient
echo'begin';
 
    function SendSMS() {         
        $loginEmail = "spread@reasonables.com";
        $APIKey = '****';
        $category = array(); # ContactList can be null 
        $phoneSubscribers = array('13800138000'); #must be a arry of string, not a string
        $SMSContent = "Download NoClone at http://noclone.net now!!";
        $sender = ''; //$sender = 'AcnePro'; if you don't have senderid please set to null ,else set your sender 
        $schedule = time();
        $campaignStatus ='Waiting';
         
        $paraArray = array(
            'loginEmail'        => $loginEmail,
            'APIKey'            => $APIKey,
            'SMSContent'        => $SMSContent,
            'sender'            => $sender,
            'schedule'          => $schedule,
            'campaignStatus'    => $campaignStatus,
            'phoneSubscribers'  => $phoneSubscribers,
            'category'          => $category
        );
        $Client = new SoapClient("http://service.rspread.com/Service.asmx?WSDL");
        $cpnId = $Client -> SendSMS( $paraArray );
        echo serialize($cpnId);
    }
 
echo SendSMS();
POST {{YOUR_API_URL}}/service.asmx 

Content-Type: application/soap+xml; charset=utf-8
Content-Length: {{length}}

<!-- Send Transactional SMS HTTP Body -->
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <SendSMS xmlns="http://service.reasonablespread.com/">
      <loginEmail>Spread@reasonables.com</loginEmail>
      <APIKey>TEST0000-TEST-0000-TEST-0000TEST0000</APIKey>
      <SMSContent>Test</SMSContent>
      <sender></sender>
      <schedule>2022-12-20T14:50:50</schedule>
      <campaignStatus>Waiting</campaignStatus>
      <phoneSubscribers>
        <string>85212345678</string>
        <string>85212345679</string>
      </phoneSubscribers>
      <category></category>
    </SendSMS>
  </soap12:Body>
</soap12:Envelope>

<!-- Send Promotional SMS HTTP Body -->
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <SendSMS xmlns="http://service.reasonablespread.com/">
      <loginEmail>Spread@reasonables.com</loginEmail>
      <APIKey>TEST0000-TEST-0000-TEST-0000TEST0000</APIKey>
      <SMSContent>Test</SMSContent>
      <sender></sender>
      <schedule>2022-12-20T14:50:50</schedule>
      <campaignStatus>Waiting</campaignStatus>
      <phoneSubscribers></phoneSubscribers>
      <category>
          <string>subscriptionName</string>
          <string>contactListName</string>
      </category>
    </SendSMS>
  </soap12:Body>
</soap12:Envelope>