要访问ExpertSender 的 API,你必须于每个请求都提供你的API key。API key 是一个数字和字母组成的随机字符串,ExpertSender系统为每个业务单元自动生成。
<ApiRequest
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xmlns:xs=”http://www.w3.org/2001/XMLSchema”>
<ApiKey>YOUR_API_KEY_HERE</ApiKey>
<Data xsi:type=”Subscriber”>
<Mode>AddAndUpdate</Mode>
<Force>true</Force>
<ListId>1</ListId>
<Email>john.smith@domain.com</Email>
<Firstname>John</Firstname>
<Lastname>Smith</Lastname>
<TrackingCode>123</TrackingCode>
<Vendor>xyz</Vendor>
<Ip>11.22.33.44</Ip>
<Properties>
<Property>
<Id>2</Id>
<Value xsi:type=”xs:string”>student</Value>
</Property>
<Property>
<Id>3</Id>
<Value xsi:type=”xs:dateTime”>1985-03-12</Value>
</Property>
</Properties>
</Data>
</ApiRequest>
|
请求是由两部分组成的:
1. ApiKey – 这是您的API key,认证需要
2. 数据 – 这是请求数据。其内容可能会有所不同,这取决于所操作的资源。数据类型应始终指定使用xsi:type属性 (xsi:type attribute)。
要返回任何数据(大多为GET请求方式)时,或在出现错误的情况下,一段XML语言将被提供。 应答内容类型(content-type)设置为text/xml且应答主体包含XML语言。格式如下:
正确的应答Correct Response:
<ApiResponse xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”xmlns:xsd=”http://www.w3.org/2001/XMLSchema”> <Data xsi:type=”…”> … </Data> </ApiResponse> |
数据元素的类型和内容取决于所访问的数据资源类型(见下文不同数据资源的详细描述)。
<ApiResponse xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”xmlns:xsd=”http://www.w3.org/2001/XMLSchema”> <ErrorMessage> <Code>400</Code> <Message>Email is invalid; </Message> </ErrorMessage> </ApiResponse> |
错误代码(包括返回的HTTP应答代码)以及一段解释性错误消息会被返回。