Skip to main content
August 2, 2013
Question

how to get latest leads using marketo api

  • August 2, 2013
  • 7 replies
  • 1354 views
I'm trying to get the latest leads for my account, limited for example to the last 10 minutes.

i was able to get leds by e-mail with getLead() but how can i do this using the date field?

Any ideas?

Thanks!
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

7 replies

August 4, 2013
Veronica,
You should use getMultipleLeads().  Like getLead, this operation retrieves lead records from Marketo.  Instead of data for a single lead, this call returns data for a batch of leads which match the criteria passed into the leadSelector parameter. The criteria can be a date range, such as the last updated date; an array of lead keys; or a static list.
August 5, 2013
Hi Raj,
I'm trying to use that function but seems to be not defined in the Marketo class i'm using.

Where can i find and download the right .php file with the class and all these functionalities?

Thank you!
August 5, 2013
Nicolas,
Where did you get the Marketo class from?  The file that we provide at http://community.marketo.com/MarketoArticle?id=kA050000000Kz59CAC has the classes that you are looking for
August 6, 2013
Thanks for the fast reply Raj,

I don't see that function defined on the declaration of the mktSampleMktowsClient class.
Am i doing it the right way?

This is the code:

require_once('Marketo_SOAP_PHP_Client.php');
 
$marketo_client = new mktSampleMktowsClient('******', '****', 'https://*******.mktoapi.com/soap/mktows/2_1');
 
$leads = $marketo_client->getMultipleLeads('EMAIL', 'test@asdasd.com');
August 6, 2013
Nicolas,
With PHP, you don't even have to rely on the client classes.  Here's standalone that should work for you -

https://github.com/rajrajamani/Marketo/blob/master/php/soapCodeSamples/getMultipleLeads.php
August 6, 2013
It works! thanks Raj!

Now i can't find in the documentation how i'm supposed to use 'latestUpdatedAt' and how i have to introduce the date rage.
I need the latest ones, say for the last 10 minutes.

This is the vars i need to touch, right?

$leadSel = new stdClass();
$leadSel->keyType = 'latestUpdatedAt';
 
$keyValues = array();
$leadKeys = new stdClass();
$leadKeys->stringItem = $keyValues;
$leadSel->keyValues = $leadKeys;
 
$leadSelSoap = new stdClass();
$leadSelSoap = array("leadSelector" => $leadSel);

Thank you so much

-Nicolás.
August 6, 2013
Here's the modification to get all the leads that were updated between noon and 3:45pm on 08/02/2013.  Please modify as required

// Create Request
$leadSel = new stdClass();
// $leadSel->keyType = 'EMAIL';
 
// $keyValues = array("formtest1@marketo.com", "joe@marketo.com");
// $leadKeys = new stdClass();
// $leadKeys->latestUpdatedAt = $keyValues;
// $leadSel->keyValues = $leadKeys;
$leadSel->latestUpdatedAt = "2013-08-02T15:45:00-07:00";
$leadSel->oldestUpdatedAt = "2013-08-02T12:00:00-07:00";
 
 
$leadSelSoap = new stdClass();
$leadSelSoap = array("leadSelector" => $leadSel);
 
// $leadSelParams = array("leadSelector" => $leadSelSoap, "batchSize" => 10, "streamPosition" => $startPosition);
// $params = array("paramsGetMultipleLeads" => $leadSelParams);
 
$leadSelSoap = new SoapVar($leadSel, SOAP_ENC_OBJECT, "LastUpdateAtSelector", "http://www.marketo.com/mktows/");
 
$params = new  stdClass();
$params->leadSelector = $leadSelSoap;
$params->batchSize = 100;
 
$soapClient = new SoapClient($marketoSoapEndPoint ."?WSDL", $options);
try {
  $leads = $soapClient->__soapCall('getMultipleLeads', array($params), $options, $authHdr);
}