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.'/SforceEnterpriseClient.php');
require_once ('../../misc/globalconstants.php');
try {
$mySforceConnection = new SforceEnterpriseClient();
$mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/enterprise.wsdl.xml');
$mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);
$sObject = new stdclass();
$sObject->FirstName = 'Smith';
$sObject->LastName = 'John';
$sObject->Phone = '510-555-5555';
$sObject->BirthDate = '1927-01-25';
echo "**** Creating the following:\n";
$createResponse = $mySforceConnection->create(array($sObject), 'Contact');
print_r($createResponse);
$id = $createResponse->id;
echo "***** Updating record *****\n";
$sObject->Id = $id;
$sObject->Phone = '999-999-9999';
$updateResponse = $mySforceConnection->update(array ($sObject), "Contact");
print_r($updateResponse);
echo "***** Wait 60 seconds *****\n";
sleep('60');
$currentTime = mktime();
// assume that update occured within the last 5 mins.
$startTime = $currentTime-(60*10);
$endTime = $currentTime;
echo "***** Get Updated Leads *****\n";
$getUpdateddResponse = $mySforceConnection->getUpdated('Contact', $startTime, $endTime);
print_r($getUpdateddResponse);
} catch (Exception $e) {
echo $mySforceConnection->getLastRequest();
print_r($e);
}
?>
Sample Output
**** Creating the following:
stdClass Object
(
[id] => 0035000000UbiHXAAZ
[success] => 1
)
***** Updating record *****
stdClass Object
(
[id] => 0035000000UbiHXAAZ
[success] => 1
)
***** Wait 60 seconds *****
***** Get Updated Leads *****
stdClass Object
(
[ids] => Array
(
[0] => 0035000000UbiEqAAJ
[1] => 0035000000UbiHXAAZ
)
[latestDateCovered] => 2008-01-30T01:05:00.000Z
)