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>