getleadchanges
此础笔滨与getLeadActivity
类似,不同之处在于它同时在多个Lead上运行。 该操作会检查已创建的新商机、商机字段更新和其他活动。
结果包含导致更改以及流位置在大型结果集中分页的活动。
必须包括一个输入参数,用于标识希望在结果中返回的活动过滤器。 如果您需要所有活动,则可以传递一个空白值。 对于多个活动过滤器,传入活动过滤器列表。
一些示例活动类型为:“访问网页”、“填写表单”和“单击链接”。
在SOAP API版本2_2之后,您可以包含leadSelector
。
对于LastUpdateAtSelector
,oldestUpdatedAt
值将对应于startPosition
中的oldestCreatedAt
值。 并且latestUpdatedAt
值将对应于startPosition
中的latestCreatedAt
值。
注意: LeadKeySelector
中支持的潜在客户数限制为100。 如果潜在客户数超过100,则API会引发参数异常并返回SOAP错误。
请求
字段名称
必需/可选
描述
activityFilter->includeAttributes->activityType
可选(已弃用)改用
activityNameFilter
将响应限制为仅包含指定的那些活动类型。 有关所有活动类型,请参阅WSDL 。
activityFilter->excludeAttributes->activityType
可选
将响应限制为排除指定的活动类型。 有关所有活动类型,请参阅WSDL 。 注意:您不能在同一调用中同时指定
includeAttributes
和excludeAttributes
。activityNameFilter
可选
将响应限制为仅包含指定的活动过滤器。
batchSize
可选
要返回的最大记录数。 系统限制为1,000或
batchSize
,以较小者为准。startPosition
必需
用于在大量活动响应中分页。
startPosition->offset
可选
偏移值由以前的调用响应字段苍别飞厂迟补谤迟笔辞蝉颈迟颈辞苍->辞蹿蹿蝉别迟返回。
startPosition->oldestCreatedAt
可选
用于筛选结果以仅包含自oldestCreatedAt以来创建的潜在客户的时间戳。 注意:您可以使用
LastUpdateAtSelector->oldestUpdatedAt
时间戳指定oldestCreatedAt
。startPosition->activityCreatedAt
可选
用于筛选结果以仅包含自activityCreatedAt以来具有活动的潜在客户的时间戳。 注意:您可以使用
LastUpdateAtSelector->latestUpdatedAt
时间戳指定activityCreatedAt
。商机选择器
可选
可以是以下3种类型之一:
LeadKeySelector
、StaticListSelector
、LastUpdateAtSelector
LeadKeySelector: leadSelector->keyType
必需
您希望查询的ID类型。 值包括
IDNUM
、COOKIE
、EMAIL
、LEADOWNEREMAIL
、SFDCACCOUNTID
、SFDCCONTACTID
、SFDCLEADID
、SFDCLEADOWNERID
、SFDCOPPTYID
。LeadKeySelector: leadSelector->keyValues->stringItem
必需
键值列表。 即,“lead@email.com”
StaticListSelector: leadSelector->staticListName
leadSelector->staticListId
存在时可选静态列表的名称
StaticListSelector: leadSelector->staticListId
leadSelector->staticListName
存在时可选静态列表的滨顿
请求齿惭尝
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.marketo.com/mktows/">
<SOAP-ENV:Header>
<ns1:AuthenticationHeader>
<mktowsUserId>demo17_1_809934544BFABAE58E5D27</mktowsUserId>
<requestSignature>59e88471266a7495590941586ef6a96849ea8e11</requestSignature>
<requestTimestamp>2013-08-02T17:22:53-07:00</requestTimestamp>
</ns1:AuthenticationHeader>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:paramsGetLeadChanges>
<startPosition>
<oldestCreatedAt>2013-08-01T00:13:13+00:00</oldestCreatedAt>
</startPosition>
<activityNameFilter>
<stringItem>Visit Webpage</stringItem>
<stringItem>Click Link</stringItem>
</activityNameFilter>
<batchSize>10</batchSize>
</ns1:paramsGetLeadChanges>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
响应齿惭尝
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://www.marketo.com/mktows/">
<SOAP-ENV:Body>
<ns1:successGetLeadChanges>
<result>
<returnCount>10</returnCount>
<remainingCount>576</remainingCount>
<newStartPosition>
<latestCreatedAt xsi:nil="true" />
<oldestCreatedAt>2013-08-01T00:13:13+00:00</oldestCreatedAt>
<activityCreatedAt xsi:nil="true" />
<offset>ID:1086173</offset>
</newStartPosition>
<leadChangeRecordList>
<leadChangeRecord>
<id>1037189</id>
<activityDateTime>2013-08-01T00:00:09-05:00</activityDateTime>
<activityType>Change Data Value</activityType>
<mktgAssetName>Lead Score</mktgAssetName>
<activityAttributes>
<attribute>
<attrName>Attribute Name</attrName>
<attrType xsi:nil="true" />
<attrValue>Lead Score</attrValue>
</attribute>
<attribute>
<attrName>Old Value</attrName>
<attrType xsi:nil="true" />
<attrValue>402</attrValue>
</attribute>
<attribute>
<attrName>New Value</attrName>
<attrType xsi:nil="true" />
<attrValue>403</attrValue>
</attribute>
<attribute>
<attrName>Reason</attrName>
<attrType xsi:nil="true" />
<attrValue>Changed by Smart Campaign Japanese form fillout.test time zone action Change Score</attrValue>
</attribute>
<attribute>
<attrName>Step ID</attrName>
<attrType xsi:nil="true" />
<attrValue>19582</attrValue>
</attribute>
<attribute>
<attrName>Choice Number</attrName>
<attrType xsi:nil="true" />
<attrValue>0</attrValue>
</attribute>
<attribute>
<attrName>Lead ID</attrName>
<attrType xsi:nil="true" />
<attrValue>84105</attrValue>
</attribute>
</activityAttributes>
<campaign>Japanese form fillout.test time zone</campaign>
<mktPersonId>84105</mktPersonId>
</leadChangeRecord>
<leadChangeRecord>
<id>1037190</id>
<activityDateTime>2013-08-01T02:37:17-05:00</activityDateTime>
<activityType>Change Data Value</activityType>
<mktgAssetName>Marketo Social Facebook Reach</mktgAssetName>
<activityAttributes>
<attribute>
<attrName>Attribute Name</attrName>
<attrType xsi:nil="true" />
<attrValue>Marketo Social Facebook Reach</attrValue>
</attribute>
<attribute>
<attrName>Old Value</attrName>
<attrType xsi:nil="true" />
<attrValue>574</attrValue>
</attribute>
<attribute>
<attrName>New Value</attrName>
<attrType xsi:nil="true" />
<attrValue>571</attrValue>
</attribute>
<attribute>
<attrName>Reason</attrName>
<attrType xsi:nil="true" />
<attrValue>Form fill-out, URL: <unknown></attrValue>
</attribute>
<attribute>
<attrName>Lead ID</attrName>
<attrType xsi:nil="true" />
<attrValue>1086478</attrValue>
</attribute>
</activityAttributes>
<mktPersonId>1086478</mktPersonId>
</leadChangeRecord>
<leadChangeRecord>
<id>1037193</id>
<activityDateTime>2013-08-01T11:19:26-05:00</activityDateTime>
<activityType>Change Data Value</activityType>
<mktgAssetName>Lead Score</mktgAssetName>
<activityAttributes>
<attribute>
<attrName>Attribute Name</attrName>
<attrType xsi:nil="true" />
<attrValue>Lead Score</attrValue>
</attribute>
<attribute>
<attrName>Old Value</attrName>
<attrType xsi:nil="true" />
<attrValue />
</attribute>
<attribute>
<attrName>New Value</attrName>
<attrType xsi:nil="true" />
<attrValue>1</attrValue>
</attribute>
<attribute>
<attrName>Reason</attrName>
<attrType xsi:nil="true" />
<attrValue>Changed by Smart Campaign Visit any web page action Change Score</attrValue>
</attribute>
<attribute>
<attrName>Step ID</attrName>
<attrType xsi:nil="true" />
<attrValue>11156</attrValue>
</attribute>
<attribute>
<attrName>Choice Number</attrName>
<attrType xsi:nil="true" />
<attrValue>0</attrValue>
</attribute>
<attribute>
<attrName>Lead ID</attrName>
<attrType xsi:nil="true" />
<attrValue>1090235</attrValue>
</attribute>
</activityAttributes>
<campaign>Visit any web page</campaign>
<mktPersonId>1090235</mktPersonId>
</leadChangeRecord>
<leadChangeRecord>
<id>1082831</id>
<activityDateTime>2013-08-01T13:10:17-05:00</activityDateTime>
<activityType>Change Data Value</activityType>
<mktgAssetName>First Name</mktgAssetName>
<activityAttributes>
<attribute>
<attrName>Attribute Name</attrName>
<attrType xsi:nil="true" />
<attrValue>First Name</attrValue>
</attribute>
<attribute>
<attrName>Old Value</attrName>
<attrType xsi:nil="true" />
<attrValue>George</attrValue>
</attribute>
<attribute>
<attrName>New Value</attrName>
<attrType xsi:nil="true" />
<attrValue>Travis</attrValue>
</attribute>
<attribute>
<attrName>Reason</attrName>
<attrType xsi:nil="true" />
<attrValue>SOAP API</attrValue>
</attribute>
<attribute>
<attrName>Lead ID</attrName>
<attrType xsi:nil="true" />
<attrValue>1089965</attrValue>
</attribute>
</activityAttributes>
<mktPersonId>1089965</mktPersonId>
</leadChangeRecord>
<leadChangeRecord>
<id>1082843</id>
<activityDateTime>2013-08-01T13:10:19-05:00</activityDateTime>
<activityType>Change Data Value</activityType>
<mktgAssetName>Last Name</mktgAssetName>
<activityAttributes>
<attribute>
<attrName>Attribute Name</attrName>
<attrType xsi:nil="true" />
<attrValue>Last Name</attrValue>
</attribute>
<attribute>
<attrName>Old Value</attrName>
<attrType xsi:nil="true" />
<attrValue>of the Jungle</attrValue>
</attribute>
<attribute>
<attrName>New Value</attrName>
<attrType xsi:nil="true" />
<attrValue>Kaufman</attrValue>
</attribute>
<attribute>
<attrName>Reason</attrName>
<attrType xsi:nil="true" />
<attrValue>SOAP API</attrValue>
</attribute>
<attribute>
<attrName>Lead ID</attrName>
<attrType xsi:nil="true" />
<attrValue>1089965</attrValue>
</attribute>
</activityAttributes>
<mktPersonId>1089965</mktPersonId>
</leadChangeRecord>
<leadChangeRecord>
<id>1086153</id>
<activityDateTime>2013-08-01T13:21:51-05:00</activityDateTime>
<activityType>Change Data Value</activityType>
<mktgAssetName>Urgency</mktgAssetName>
<activityAttributes>
<attribute>
<attrName>Attribute Name</attrName>
<attrType xsi:nil="true" />
<attrValue>Urgency</attrValue>
</attribute>
<attribute>
<attrName>Old Value</attrName>
<attrType xsi:nil="true" />
<attrValue />
</attribute>
<attribute>
<attrName>New Value</attrName>
<attrType xsi:nil="true" />
<attrValue>25</attrValue>
</attribute>
<attribute>
<attrName>Reason</attrName>
<attrType xsi:nil="true" />
<attrValue>Changed by Smart Campaign Operational Campaign - ML action Change Score</attrValue>
</attribute>
<attribute>
<attrName>Source</attrName>
<attrType xsi:nil="true" />
<attrValue>Lead update</attrValue>
</attribute>
<attribute>
<attrName>Lead ID</attrName>
<attrType xsi:nil="true" />
<attrValue>1090236</attrValue>
</attribute>
</activityAttributes>
<mktPersonId>1090236</mktPersonId>
</leadChangeRecord>
<leadChangeRecord>
<id>1086166</id>
<activityDateTime>2013-08-01T13:21:53-05:00</activityDateTime>
<activityType>Change Data Value</activityType>
<mktgAssetName>Relative Urgency</mktgAssetName>
<activityAttributes>
<attribute>
<attrName>Attribute Name</attrName>
<attrType xsi:nil="true" />
<attrValue>Relative Urgency</attrValue>
</attribute>
<attribute>
<attrName>Old Value</attrName>
<attrType xsi:nil="true" />
<attrValue />
</attribute>
<attribute>
<attrName>New Value</attrName>
<attrType xsi:nil="true" />
<attrValue>1</attrValue>
</attribute>
<attribute>
<attrName>Reason</attrName>
<attrType xsi:nil="true" />
<attrValue>Changed by Smart Campaign Operational Campaign - ML action Change Score</attrValue>
</attribute>
<attribute>
<attrName>Source</attrName>
<attrType xsi:nil="true" />
<attrValue>Lead update</attrValue>
</attribute>
<attribute>
<attrName>Lead ID</attrName>
<attrType xsi:nil="true" />
<attrValue>1090236</attrValue>
</attribute>
</activityAttributes>
<mktPersonId>1090236</mktPersonId>
</leadChangeRecord>
<leadChangeRecord>
<id>1086167</id>
<activityDateTime>2013-08-01T13:21:53-05:00</activityDateTime>
<activityType>Change Data Value</activityType>
<mktgAssetName>Relative Score</mktgAssetName>
<activityAttributes>
<attribute>
<attrName>Attribute Name</attrName>
<attrType xsi:nil="true" />
<attrValue>Relative Score</attrValue>
</attribute>
<attribute>
<attrName>Old Value</attrName>
<attrType xsi:nil="true" />
<attrValue />
</attribute>
<attribute>
<attrName>New Value</attrName>
<attrType xsi:nil="true" />
<attrValue>1</attrValue>
</attribute>
<attribute>
<attrName>Reason</attrName>
<attrType xsi:nil="true" />
<attrValue>Changed by Smart Campaign Operational Campaign - ML action Change Score</attrValue>
</attribute>
<attribute>
<attrName>Source</attrName>
<attrType xsi:nil="true" />
<attrValue>Lead update</attrValue>
</attribute>
<attribute>
<attrName>Lead ID</attrName>
<attrType xsi:nil="true" />
<attrValue>1090236</attrValue>
</attribute>
</activityAttributes>
<mktPersonId>1090236</mktPersonId>
</leadChangeRecord>
<leadChangeRecord>
<id>1086169</id>
<activityDateTime>2013-08-01T13:21:53-05:00</activityDateTime>
<activityType>Change Data Value</activityType>
<mktgAssetName>Priority</mktgAssetName>
<activityAttributes>
<attribute>
<attrName>Attribute Name</attrName>
<attrType xsi:nil="true" />
<attrValue>Priority</attrValue>
</attribute>
<attribute>
<attrName>Old Value</attrName>
<attrType xsi:nil="true" />
<attrValue />
</attribute>
<attribute>
<attrName>New Value</attrName>
<attrType xsi:nil="true" />
<attrValue>70</attrValue>
</attribute>
<attribute>
<attrName>Reason</attrName>
<attrType xsi:nil="true" />
<attrValue>Changed by Smart Campaign Operational Campaign - ML action Change Score</attrValue>
</attribute>
<attribute>
<attrName>Source</attrName>
<attrType xsi:nil="true" />
<attrValue>Lead update</attrValue>
</attribute>
<attribute>
<attrName>Lead ID</attrName>
<attrType xsi:nil="true" />
<attrValue>1090236</attrValue>
</attribute>
</activityAttributes>
<mktPersonId>1090236</mktPersonId>
</leadChangeRecord>
<leadChangeRecord>
<id>1086173</id>
<activityDateTime>2013-08-01T13:21:53-05:00</activityDateTime>
<activityType>Change Data Value</activityType>
<mktgAssetName>Lead Score</mktgAssetName>
<activityAttributes>
<attribute>
<attrName>Attribute Name</attrName>
<attrType xsi:nil="true" />
<attrValue>Lead Score</attrValue>
</attribute>
<attribute>
<attrName>Old Value</attrName>
<attrType xsi:nil="true" />
<attrValue />
</attribute>
<attribute>
<attrName>New Value</attrName>
<attrType xsi:nil="true" />
<attrValue>25</attrValue>
</attribute>
<attribute>
<attrName>Reason</attrName>
<attrType xsi:nil="true" />
<attrValue>Changed by Smart Campaign Operational Campaign - ML action Change Score</attrValue>
</attribute>
<attribute>
<attrName>Step ID</attrName>
<attrType xsi:nil="true" />
<attrValue>12259</attrValue>
</attribute>
<attribute>
<attrName>Choice Number</attrName>
<attrType xsi:nil="true" />
<attrValue>0</attrValue>
</attribute>
<attribute>
<attrName>Lead ID</attrName>
<attrType xsi:nil="true" />
<attrValue>1090236</attrValue>
</attribute>
</activityAttributes>
<campaign>Operational Campaign - ML</campaign>
<mktPersonId>1090236</mktPersonId>
</leadChangeRecord>
</leadChangeRecordList>
</result>
</ns1:successGetLeadChanges>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
示例代码 — PHP
<?php
$debug = true;
$marketoSoapEndPoint = ""; // CHANGE ME
$marketoUserId = ""; // CHANGE ME
$marketoSecretKey = ""; // CHANGE ME
$marketoNameSpace = "http://www.marketo.com/mktows/";
// Create Signature
$dtzObj = new DateTimeZone("America/Los_Angeles");
$dtObj = new DateTime('now', $dtzObj);
$timeStamp = $dtObj->format(DATE_W3C);
$encryptString = $timeStamp . $marketoUserId;
$signature = hash_hmac('sha1', $encryptString, $marketoSecretKey);
// Create SOAP Header
$attrs = new stdClass();
$attrs->mktowsUserId = $marketoUserId;
$attrs->requestSignature = $signature;
$attrs->requestTimestamp = $timeStamp;
$authHdr = new SoapHeader($marketoNameSpace, 'AuthenticationHeader', $attrs);
$options = array("connection_timeout" => 600, "location" => $marketoSoapEndPoint);
if ($debug) {
$options["trace"] = 1;
}
// Create Request
$params = new stdClass();
$filter = new stdClass();
$keyValues = array("Visit Webpage", "Click Link");
$filter->stringItem = $keyValues;
$params->activityNameFilter = $filter;
$streamPos = new stdClass();
$streamPos->oldestCreatedAt = "2013-08-01T00:13:13+00:00";
$params->startPosition = $streamPos;
$params->batchSize = 10;
$authHdr = new SoapHeader($marketoNameSpace, 'AuthenticationHeader', $attrs);
$client = new SoapClient($marketoSoapEndPoint ."?WSDL", $options);
$doPage = true;
while($doPage) {
$success = $client->__soapCall('getLeadChanges', array($params), null, $authHdr);
$result = $success->result;
$doPage = ($result->remainingCount > 0);
$streamPos = $result->newStartPosition;
$params->startPosition = $streamPos;
if ($debug) {
print "RAW request:\n" .$client->__getLastRequest() ."\n";
print "RAW response:\n" .$client->__getLastResponse() ."\n";
}
}
return;
?>
示例代码 — Java
import com.marketo.mktows.*;
import java.net.URL;
import javax.xml.namespace.QName;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.datatype.DatatypeFactory;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.codec.binary.Hex;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.Marshaller;
import java.util.GregorianCalendar;
public class GetLeadChanges {
public static void main(String[] args) {
System.out.println("Executing Get Lead Changes");
try {
URL marketoSoapEndPoint = new URL("CHANGE ME" + "?WSDL");
String marketoUserId = "CHANGE ME";
String marketoSecretKey = "CHANGE ME";
QName serviceName = new QName("http://www.marketo.com/mktows/", "MktMktowsApiService");
MktMktowsApiService service = new MktMktowsApiService(marketoSoapEndPoint, serviceName);
MktowsPort port = service.getMktowsApiSoapPort();
// Create Signature
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
String text = df.format(new Date());
String requestTimestamp = text.substring(0, 22) + ":" + text.substring(22);
String encryptString = requestTimestamp + marketoUserId;
SecretKeySpec secretKey = new SecretKeySpec(marketoSecretKey.getBytes(), "HmacSHA1");
Mac mac = Mac.getInstance("HmacSHA1");
mac.init(secretKey);
byte[] rawHmac = mac.doFinal(encryptString.getBytes());
char[] hexChars = Hex.encodeHex(rawHmac);
String signature = new String(hexChars);
// Set Authentication Header
AuthenticationHeader header = new AuthenticationHeader();
header.setMktowsUserId(marketoUserId);
header.setRequestTimestamp(requestTimestamp);
header.setRequestSignature(signature);
// Create Request
ParamsGetLeadChanges request = new ParamsGetLeadChanges();
ObjectFactory objectFactory = new ObjectFactory();
JAXBElement<Integer> batchSize = objectFactory.createParamsGetLeadActivityBatchSize(10);
request.setBatchSize(batchSize);
ArrayOfString activities = new ArrayOfString();
activities.getStringItems().add("Visit Webpage");
activities.getStringItems().add("Click Link");
JAXBElement<ArrayOfString> activityFilter = objectFactory.createParamsGetLeadChangesActivityNameFilter(activities);
request.setActivityNameFilter(activityFilter);
// Create oldestCreateAt timestamp from 5 days ago
GregorianCalendar gc = new GregorianCalendar();
gc.setTimeInMillis(new Date().getTime());
gc.add( GregorianCalendar.DAY_OF_YEAR, -5);
DatatypeFactory factory = DatatypeFactory.newInstance();
JAXBElement<XMLGregorianCalendar> oldestCreateAtValue =objectFactory.createStreamPositionOldestCreatedAt(factory.newXMLGregorianCalendar(gc));
StreamPosition sp = new StreamPosition();
sp.setOldestCreatedAt(oldestCreateAtValue);
request.setStartPosition(sp);
SuccessGetLeadChanges result = port.getLeadChanges(request, header);
JAXBContext context = JAXBContext.newInstance(SuccessGetLeadChanges.class);
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
m.marshal(result, System.out);
}
catch(Exception e) {
e.printStackTrace();
}
}
}
示例代码 — Ruby
require 'savon' # Use version 2.0 Savon gem
require 'date'
mktowsUserId = "" # CHANGE ME
marketoSecretKey = "" # CHANGE ME
marketoSoapEndPoint = "" # CHANGE ME
marketoNameSpace = "http://www.marketo.com/mktows/"
#Create Signature
Timestamp = DateTime.now
requestTimestamp = Timestamp.to_s
encryptString = requestTimestamp + mktowsUserId
digest = OpenSSL::Digest.new('sha1')
hashedsignature = OpenSSL::HMAC.hexdigest(digest, marketoSecretKey, encryptString)
requestSignature = hashedsignature.to_s
#Create SOAP Header
headers = {
'ns1:AuthenticationHeader' => { "mktowsUserId" => mktowsUserId, "requestSignature" => requestSignature,
"requestTimestamp" => requestTimestamp
}
}
client = Savon.client(wsdl: 'http://app.marketo.com/soap/mktows/2_3?WSDL', soap_header: headers, endpoint: marketoSoapEndPoint, open_timeout: 90, read_timeout: 90, namespace_identifier: :ns1, env_namespace: 'SOAP-ENV')
#Create Request
request = {
:start_position => {
:oldest_created_at => "2013-08-01T00:13:13+00:00" },
:activity_name_filter => {
:stringItem => ["Visit Webpage", "Click Link"] },
:batch_size => "10"
}
response = client.call(:get_lead_changes, message: request)
puts response
recommendation-more-help
bb269a6d-047a-4bf7-9acd-23ad9a63dc59