Skip Navigation Links.
展开 最小化

SpreadWebServcie.UploadContactListFile Method

上傳聯絡人數據文件.

參數

參數

類型

描述

loginEmail

String

Spread賬號的登錄郵箱.

loginPassword

String

Spread賬號的登錄密碼或者API Key.

fileType

String

上傳數據文件類型包括".xls", ".csv", ".xlsx".

myFileStream

base64Binary

上傳數據文件流(小于100M). 上傳文件模板

ContactListName

String

聯絡人名單的名稱.

返回結果

String or Exception. 如果上傳成功,返回String:Spread has received your data and will send you an email after upload complete. (RequestID:AAAABBBB-CCCC-DDDD-EEEE-FFFFGGGGHHHH).

狀態/場景

返回類型

HTTP狀態碼

返回信息

成功上傳聯絡人文件,並在處理。

String

200

Spread has received your data and will send you an email after upload complete. (RequestID:AAAABBBB-CCCC-DDDD-EEEE-FFFFGGGGHHHH)

請求API時使用錯誤的賬號或者API Key;
請求API時使用一個不存在的聯絡人名單名稱。
Exception 500

返回異常含錯誤信息'Contact List "SubscriptionName" does not exist!'.

上傳錯誤類型的文件,比如 *.jpg, *.doc 或者其它類型文件。 Exception 500

返回異常含錯誤信息'File extensions is not allowed. (Extensions Allowed: .csv|.xls|.xlsx)'.

其它錯誤情況。 Exception 500

返回異常含錯誤信息 'Upload failed. ' 和其它的關於錯誤的内容。

例子

string loginEmail = "Spread@reasonables.com";

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

System.IO.FileStream fileStream = new System.IO.FileStream(@"D:\content1.xlsx", System.IO.FileMode.Open);

byte[] arrayByte = new byte[fileStream.Length];

fileStream.Read(arrayByte, 0, Convert.ToInt32(fileStream.Length));

fileStream.Close();

SpreadAPI.SpreadWebService MySpread = new SpreadAPI.SpreadWebService();

string result = MySpread.UploadContactListFile(loginEmail, loginPassword, ".xlsx", arrayByte, "test 20130204");

Dim loginEmail As String = "Spread@reasonables.com"

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

Dim fileStream As New System.IO.FileStream("D:\content1.xlsx", IO.FileMode.Open)

Dim arrayByte = New Byte(fileStream.Length - 1) {}

fileStream.Read(arrayByte, 0, fileStream.Length)

fileStream.Close()

Dim MySpread As New SpreadAPI.SpreadWebService()

Dim result As String = MySpread.UploadContactListFile(loginEmail, loginPassword, ".xlsx", arrayByte, "test 20130204")

/**
* @name     uploadContactListFile
* @function add multi email receivers
* @param
*  optInType  'Off'
*  (fiel import)
*		$data = the absolute path of file
* @return
*	errorMsg	failed information
*  Msg			success information
*/

public function uploadContactListFile($loginEmail,$password,$listName,$data ){
	    $fileContent = file_get_contents( $data );
            $fileName = array_pop( explode( '/', $data ) );
            $fileExt = array_pop( explode( '.', $fileName ) );
	    $addInArr = array(
			    'loginEmail'	    => $loginEmail,
			    'loginPassword'	    => $password,
			    'fileType'	            => '.'.$fileExt,
			    'myFileStream'	    => $fileContent,
			    'ContactListName'       => $listName
			    );
	    $Client = new SoapClient("http://service.rspread.com/Service.asmx?WSDL");		
	    $Client -> soap_defencoding = 'utf-8';
	    $Client -> decode_utf8 = false;
	    $Client -> xml_encoding = 'utf-8';
            return $Client -> UploadContactListFile( $addInArr );
}
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>
    <UploadContactListFile xmlns="http://service.reasonablespread.com/">
      <loginEmail>Spread@reasonables.com</loginEmail>
      <loginPassword>TEST0000-TEST-0000-TEST-0000TEST0000</loginPassword>
      <fileType>.csv</fileType>
      <myFileStream>base64Binary</myFileStream>
      <ContactListName>test 20130204</ContactListName>
    </UploadContactListFile>
  </soap12:Body>
</soap12:Envelope>