Skip Navigation Links.
展开 最小化

SpreadWebServcie.CreateCampaign Method

創建一個電子郵件活動和發送.

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.

參數

參數

類型

描述

loginEmail

String

Spread賬號的郵件地址.

password

String

Spread賬號的密碼或者 API Key.

campaignArgs

campaign

要被創建的campaign對象.

category

String[]

這個郵件活動發送到聯絡人名單的名稱.

*interval

Integer

郵件活動的類型.

interval=-1, 電子郵件只被發送一次.

interval>=0,電子郵件將在一個用戶訂閱N天后被發送.

返回結果

Integer 被創建活動的ID.

下表列出了詳細的返回情況

狀態/場景

返回類型

返回信息

成功創建群發郵件活動 Integer

被創建活動的ID,值大於0。

請求該API時"loginEmail"或者"password"錯誤。
常見技術問題解答
Exception

返回異常包含錯誤信息'LoginEmail and Password do not match!'。

請求該API時使用無效的"fromEmail",該郵箱未被添加為發件人。 Exception

返回異常包含錯誤信息 'Email 'fromEmail' has not been verified yet!'。

請求該API時使用無效的"Interval",其值小於 -1。 Exception

返回異常包含錯誤信息'Invalid Interval! Note: -1, campaign send for once only. Non-negetive number, n days after subscribers subscribe. please retry with other campaign name '。

請求該API時使用已被使用的活動名稱。 Exception

返回異常包含錯誤信息'CampaignName existed!'。

請求該API時使用未添加的聯絡人名單。 Exception

返回異常包含錯誤信息'ContactList categoryName is not exist!'。

其他異常 Exception

返回包含錯誤信息的異常。

創建群發郵件活動失敗 Integer

返回小於等於0的值

常見技術問題解答 Exception

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

例子

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>