Skip Navigation Links.
展开 最小化

SpreadWebServcie.CreateCampaign Method

It creates an email campaign and sends it out.

public int createCampaign (

string loginEmail,

string password,

Campaign campaignArgs,

string[] category,

int interval

)

Public function createCampaign( _

loginEmail As String, _

password As String, _

campaignArgs As Campaign, _

category() As String, _

interval As Integer _

) As Integer

No sample for PHP.
No sample.

Parameters

Parameter

Type

Description

loginEmail

String

The login email of your Spread account.

password

String

The password of your Spread account or API Key which you can retrieve from your Spread account (My account=> Settings).

campaignArgs

campaign

The campaign to be created.

category

String[]

The names of target subscriptions the campaign sent to.

*interval

Integer

The type of the campaign.

interval=-1, emails are sent for once only.

interval>=0, email will be sent N day(s) after a subscriber subscribed.

Return Value

Integer of the ID of the created campaign.

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

Status/Situation

Retrun Type

Retrun Message

Create campaign successfully Integer

Return the campaign Id which is greater than zore.

Call API with invalid value of "loginEmail" or "password".
FAQ Technologies
Exception

Return exception with message 'LoginEmail and Password do not match!'.

Call API with invalid value of "fromEmail" which is not added as Sender Email in the account. Exception

Return exception with message 'Email 'fromEmail' has not been verified yet!'.

Call API with invalid value of "Interval" which is less than -1. Exception

Return exception with message 'Invalid Interval! Note: -1, campaign send for once only. Non-negetive number, n days after subscribers subscribe. please retry with other campaign name '

Call API with an existed CampaignName. Exception

Return exception with message 'CampaignName existed!'.

Call API with a not existed category. Exception

Return exception with message 'ContactList categoryName is not exist!'.

Other exception. Exception

Return other exception with error message.

It is failed to create the campaign Integer

Return the number which is less than zore or equals zore.

FAQ Technologies Exception

System.NullReferenceException: Object reference not set to an instance of an object.

Example

string loginName = "spread@reasonables.com";

string loginPassword = "TEST0000-TEST-0000-TEST-0000TEST0000";

 

//Create an array of target subscriptions

string[] targetSubscriptions = new string[2];

targetSubscriptions[1] = "NoClone VIP";

targetSubscriptions[2] = "Spread VIP";

 

int interval = -1;

int campaignID;

 

//Create a Campaign object

Campaign myCampaign = new Campaign();
myCampaign.campaignName
= "NoClone Promotion";

myCampaign.from = "NoClone";

myCampaign.fromEmail = "noclone@reasonables.com";

myCampaign.subject = "NoClone 4 is released!";

myCampaign.content = "Download NoClone 4 at http://noclone.net now!";

// suggest dateTime string format "yyyy-MM-ddTHH:mm:ss" ,such as "2023-02-06T12:11:21" .
myCampaign.schedule = "2023-02-06T12:11:21";

 

//Create a SpreadWebService object and use its method.

SpreadWebService MySpread = new SpreadWebService();

 

campaignID = MySpread.createCampaign (loginName, loginPassword, myCampaign, targetSubscriptions, interval);

Dim loginName As String = "spread@reasonables.com"

Dim loginPassword As String = "TEST0000-TEST-0000-TEST-0000TEST0000"

 

'Create an array of target subscriptions

Dim targetSubscriptions() As String = New String(1) {}

targetSubscriptions(0) = "NoClone VIP"

targetSubscriptions(1) = "Spread VIP"

 

Dim interval As Integer = -1

Dim campaignID As Integer

 

'Create a Campaign object

Dim myCampaign As New Campaign

myCampaign.campaignName = "NoClone Promotion"

myCampaign.from = "NoClone"

myCampaign.fromEmail = "noclone@reasonables.com"

myCampaign.subject = "NoClone 4 is released!"

myCampaign.content = "Download NoClone 4 at http://noclone.net now!"

' suggest dateTime string format "yyyy-MM-ddTHH:mm:ss" ,such as "2023-02-06T12:11:21" .
myCampaign.schedule = "2023-02-06T12:11:21"

 

'Create a SpreadWebService object and use its method.

Dim MySpread As New SpreadWebService

 

campaignID = MySpread.createCampaign(loginName, loginPassword, myCampaign, _ targetSubscriptions, interval)

/**
    * @name     CreateCampaign
    * @function create group sending campaign
    * @param
    *  campaignargs	the object of campaign you want to create.
    *  category        the list of contacts
    *  interval        the type of campaign.
    *                      interval=-1, just send once.
    *                      interval>=0,the email will be send after.
    * @return
    *	cpnId           Campaign Id
*/
public function CreateCampaign($loginEmail,$password,$campaignArgs, $category, $interval = -1 ){
	$cpnArr = array(
		'loginEmail'	=> $loginEmail,
		'password'	=> $password,
		'campaignArgs'	=> $campaignArgs,
		'category'	=> $category,
		'interval'	=> $interval
	);
        $Client=new SoapClient("http://service.rspread.com/Service.asmx?WSDL");
	$cpnId = $Client -> createCampaign( $cpnArr );
	return $cpnId;
}
POST {{YOUR_API_URL}}/service.asmx 

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

<?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>
    <createCampaign xmlns="http://service.reasonablespread.com/">
      <loginEmail>spread@reasonables.com</loginEmail>
      <password>TEST0000-TEST-0000-TEST-0000TEST0000</password>
      <campaignArgs>
        <campaignName>NoClone Promotion</campaignName>
        <fromEmail>noclone@reasonables.com</fromEmail>
        <from>NoClone</from>
        <subject>NoClone 4 is released!</subject>
        <content>Download NoClone 4 at http://noclone.net now!&lt;div&gt;html tags 😏&lt;div&gt;</content>
        <signature></signature>
        <schedule>2023-02-06T12:11:21</schedule>
      </campaignArgs>
      <category>
        <string>NoClone VIP</string>
        <string>Spread VIP</string>
      </category>
      <interval>-1</interval>
    </createCampaign>
  </soap12:Body>
</soap12:Envelope>