Sample Call
<?php
// SOAP_CLIENT_BASEDIR - folder that contains the PHP Toolkit and your WSDL
// $USERNAME - variable that contains your Salesforce.com username (must be in the form of an email)
// $PASSWORD - variable that contains your Salesforce.ocm password
define("SOAP_CLIENT_BASEDIR", "../../soapclient");
require_once (SOAP_CLIENT_BASEDIR.'/SforcePartnerClient.php');
require_once (SOAP_CLIENT_BASEDIR.'/SforceHeaderOptions.php');
try {
$mySforceConnection = new SforcePartnerClient();
$mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/partner.wsdl.xml');
$mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);
$obj1 = new SObject();
$obj1->type = 'Lead';
$fields = array (
'Company' => 'XYZ Company',
'FirstName' => 'John',
'LastName' => 'Smith',
'LeadSource' => 'Other',
'NumberOfEmployees' => 1,
'Status' => 'Open'
);
$obj1->fields = $fields;
$createResponse = $mySforceConnection->create(array ($obj1));
echo "***** Creating Lead *****\n";
print_r($createResponse);
$obj1->Id = $createResponse->id;
$obj1->fields['LastName'] = 'Doe';
$updateResponse = $mySforceConnection->update(array ($obj1));
echo "***** Updating Lead *****\n";
print_r($updateResponse);
echo "***** Wait 60 seconds *****\n";
sleep('60');
$currentTime = mktime();
// assume that delete occured within the last 5 mins.
$startTime = $currentTime-(60*10);
$endTime = $currentTime;
echo "***** Get Updated Leads from the last 5 minutes *****\n";
$getUpdatedResponse = $mySforceConnection->getUpdated('Lead', $startTime, $endTime);
print_r($getUpdatedResponse);
} catch (Exception $e) {
print_r($e);
}
?>
Sample Output
***** Creating Lead *****
stdClass Object
(
[id] => 00Q5000000K08ELEAZ
[success] => 1
)
***** Updating Lead *****
stdClass Object
(
[id] => 00Q5000000K08ELEAZ
[success] => 1
)
***** Wait 60 seconds *****
***** Get Updated Leads from the last 5 minutes *****
stdClass Object
(
[ids] => Array
(
[0] => 00Q5000000K08C5EAJ
[1] => 00Q5000000K08CAEAZ
[2] => 00Q5000000K08EBEAZ
[3] => 00Q5000000K08EGEAZ
[4] => 00Q5000000K08ELEAZ
)
[latestDateCovered] => 2008-01-24T23:17:00.000Z
)