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>