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. 參數subscriberArgs內,email或者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>