SpreadWebServcie.AddSubscriberByInfo Method

添加了一个单一用户进入 当前的联系人名单通过他/她的电子邮件以及其他信息.例如名字, 公司、职位等.

public bool addSubscriberByInfo (

string loginEmail,

string password,

Subscriber subscriberArgs,

string subscription,

DoubleOptIn optInType

)

Public function addSubscriberByInfo( _

loginEmail As String, _

password As String, _

subscriberArgs As Subscriber, _

subscription As String, _

optInType As DoubleOptIn _

) As Boolean

No sample for PHP.
No sample.

参数

参数

类型

描述

loginEmail

String

Spread账号的登录邮箱

password

String

Spread账号的登录密码或者 API Key.

subscriberArgs

Subscriber

添加订阅者的信息

subscription

String

要添加到联系人名单的名称

optInType

DoubleOptIn

Double Opt-in option.

返回结果

HTTP状态码为200,表示添加成功。
true/false表示是否需要联系人确认订阅,参见Double Opt-In

HTTP状态码 返回信息 状态
200 true 添加成功,需要联系人确定订阅
200 false 添加成功,不需要联系人确定订阅
500 Spreader Email and Password not match! 请检查参数loginEmailpassword是否填写错误,无误后检查请求的接口链接(常见问题
500 Subscription "xxxx" does not exist! 联系人名单“xxxx”不存在
500 Please provide a subscriber email. 参数subscriberArgsemail或者homePhone为空,请至少填写其中一个参数
500 Email address "123@123" is not valid! 电子邮箱格式错误
500 Fail to add subscriber. 添加联系人失败,请联系技术人员。
500 Email address is empty and phone "86xxx" is not valid! 参数subscriberArgsemail为空,homePhone格式错误

例子

string loginName = "spread@reasonables.com";

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

string customerEmail = "test@reasonables.com";

string targetSubscription = "NoClone VIP";

DoubleOptIn addOption = DoubleOptIn.Off;

bool confirmIsNeeded;

 

//Create a Subscriber object

Subscriber customer = new Subscriber();
customer.email =
"test@reasonables.com";
customer.firstName =
"Alan";
customer.lastName =
"Wo";
customer.company =
"Reasonable Software";

 

//Create a SpreadWebService object and use its method.

SpreadWebService MySpread = new SpreadWebService();

 

confirmIsNeeded = MySpread.addSubscriberByInfo (loginName, loginPassword, customer, targetSubscription, addOption);

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

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

Dim targetSubscription As String = "NoClone VIP"

Dim addOption As DoubleOptIn = DoubleOptIn.Off

Dim confirmIsNeeded As Boolean

 

'Create a subscriber object

Dim customer As New Subscriber

customer.email = "test@reasonables.com"

customer.firstName = "Alan"

customer.lastName = "Wo"

customer.company = "Reasonable Software"

 

'Create a SpreadWebService object and use its method.

Dim MySpread As New SpreadWebService

 

confirmIsNeeded = MySpread.addSubscriberByInfo(loginName, loginPassword, customer, _ targetSubscription, addOption)

/**
* @name     addSubscriberByInfo
* @function add single subscriber's email address
* @param
* optInType  'Off'
* data	 receiver data
* (array import)	
*   $data = array(
*       'email'     =>  'spread@reasonables.com',   (required)
*       'firstName'	=>  'spread',                   (optional)
*       'lastName'	=>  'siqi',                     (optional)
*       'date1'     =>  date( 'c' )                 (optional, current time)
*       'date2'     =>  date( 'c' )                 (optional, current time)       
*       ......      =>  ......   
*	);
* @return
*	errorMsg	failed message
*  Msg			success message
*/
public function addSubscriberByInfo($loginEmail,$password,$data,$listName,$optInType){
	$addInArr = array(
		'loginEmail'	        => $loginEmail,
		'password'	        => $password,
		'subscriberArgs'        => $data,
		'subscription'	        => $listName,
		'optInType'	        => $optInType
		);

    $Client = new SoapClient("http://service.rspread.com/Service.asmx?WSDL");
	$errorMsg = $Client -> addSubscriberByInfo( $addInArr );
	return $errorMsg;
}
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>
    <addSubscriberByInfo xmlns="http://service.reasonablespread.com/">
      <loginEmail>spread@reasonables.com</loginEmail>
      <password>TEST0000-TEST-0000-TEST-0000TEST0000</password>
      <subscriberArgs>
        <email>test@reasonables.com</email>
        <firstName>Alan</firstName>
        <lastName>Wo</lastName>
        <company>Reasonable Software</company>
        <date1>2023-02-06T12:11:21</date1>
        <date2>2023-02-06T12:11:21</date2>
        <customField1>string</customField1>
      </subscriberArgs>
      <subscription>NoClone VIP</subscription>
      <optInType>Off</optInType>
    </addSubscriberByInfo>
  </soap12:Body>
</soap12:Envelope>