Skip Navigation Links.
展开 最小化

SpreadWebServcie.SendSMS Method

It creates an SMS campaign and sends it out .

Parameters

Parameter Type Description Transactional Promotional
loginEmail String The login email of your Spread account Required Required
APIKey String The API Key of your Spread account (see: How to get API account and key in Spread?) Required Required
SMSContent String The content of SMS. Required Required
sender String The Name/Number of SMS sender.
Keep this parameter null unless your account is configured with a sender.
Optional Optional
schedule DateTime Scheduled delivery time for SMS campaigns. The past time will be sent immediately.
Format: yyyy-MM-ddTHH:mm:ss. Timezone: UTC +08:00.
Promotional SMS will be sent according to this time, and transactional SMS will be sent immediately.
Required Required
campaignStatus CampaignStatus The status of SMS campaign. (CampaignStatus.Waiting,CampaignStatus.Draft) Required Required
phoneSubscribers String[] The phone number of Subscribers.
Transactional SMS fills in this parameter value, otherwise it is null.
Required Null
category String[] The names of target subscriptions the campaign sent to.
Promotional SMS fills in this parameter value, otherwise it is null.
Null Required

Fill in only one of the parameters phoneSubscribers and category, and leave the other null.

Return Value

Integer or Exception. If it success, it will return the campaign Id, otherwise it will return Exception.

Please find the details for the return message in the following table.

Status/Situation

Retrun Type

Retrun Message

Send SMS successfully or create the SMS campaign successfully.

Integer

The campaign Id. It should be more than 0.

Fail to send SMS.

Integer

Return a number equals or less than 0.

Call API with error account or API Key.

Exception

Return a exception with message 'Spreader Email and Password not match!'.

The account is expired.

Exception

Return a exception with message 'This user has expired!'.

The value of sender does not equal the setting in the account.

Exception

Return a exception with message 'Sender format error! [Sender ID]'.

There is no vendor in the account.

Exception

Return a exception with message 'Contact us at spread@reasonables.com to get SMS service.'.

There is no vendor or error vendor in the account.

Exception

Return a exception with message 'Configured vendor is error!'.

There is no SMS credit in the account.

Exception

Return a exception with message 'No SMS message credit!'.

Fail to create SMS campaign.

Exception

Return a exception with message 'Create SMS campaign fail!'.

Other Exception

Exception

Return a exception.

Example

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>