This API is just like getLeadActivity except that it operates on multiple leads at once. The operation checks for new leads created, lead field updates and other activities.
The result contains activities that caused the change along with a stream position to paginate through large result sets.
You must include an input parameter identifying which activity filters you wish to be returned in the result. If you want all activities, a blank value may be passed. For more than one activity filter, pass in a list of activity filters. The complete list of activity filter values can be found here.
Some example activity types are: ‘Visit Webpage’, ‘Fill Out Form’, and ‘Click Link’.
After SOAP API version 2_2 you can include a leadSelector.
For LastUpdateAtSelector, the oldestUpdatedAt value would correspond to the oldestCreatedAt value in the startPosition. And the latestUpdatedAt value would corresponds to the latestCreatedAt value in the startPosition.
Note: The limit number of leads supported in a LeadKeySelector is 100. If the number of leads exceeds 100, the API will throw a bad parameter exception and return a SOAP fault.
Request
Field Name |
Required/Optional |
Description |
---|---|---|
activityFilter->includeAttributes->activityType | Optional (deprecated)
Use activityNameFilter instead |
Limits the response to include only those activity types specified. See WSDL for all activity types. |
activityFilter->excludeAttributes->activityType | Optional | Limits the response to exclude those activity types specified. See WSDL for all activity types
NOTE: You cannot specify both includeAttributes and excludeAttributes within the same call. |
activityNameFilter | Optional | Limits the response to include only those activity filters specified. See all activity filter values. |
batchSize | Optional | Maximum number of records to be returned. System will limit to 1,000 or batchSize, whichever is less. |
startPosition | Required | Used to paginate through large number of activity responses. |
startPosition->offset | Optional | The offset value is returned by the previous calls response field newStartPosition->offset. |
startPosition->
oldestCreatedAt |
Optional | The timestamp used to filter results to only include leads created since the oldestCreatedAt. NOTE: You can use LastUpdateAtSelector->oldestUpdatedAt timestamp to specify oldestCreatedAt. |
startPosition->
activityCreatedAt |
Optional | The timestamp used to filter results to only include leads with activity since activityCreatedAt. NOTE: You can use LastUpdateAtSelector->latestUpdatedAt timestamp to specify activityCreatedAt. |
leadSelector | Optional | Can be one of the following 3 types:
|
LeadKeySelector: leadSelector->keyType | Required | The id type you wish to query. Values include IDNUM, COOKIE, EMAIL, LEADOWNEREMAIL, SFDCACCOUNTID, SFDCCONTACTID, SFDCLEADID, SFDCLEADOWNERID, SFDCOPPTYID. |
LeadKeySelector: leadSelector->keyValues->stringItem | Required | List of key values. i.e. “lead@email.com” |
StaticListSelector: leadSelector->staticListName | Optional when leadSelector->staticListId is present | The name of the static list |
StaticListSelector: leadSelector->staticListId | Optional when leadSelector->staticListName is present | The ID of the static list |
Request XML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<?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> |
Response XML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
<?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> |
Sample Code – PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
<?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; ?> |
Sample Code – Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
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(); } } } |
Sample Code – Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
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 |