<?php
define("SOAP_CLIENT_BASEDIR", "../../soapclient");
require_once (SOAP_CLIENT_BASEDIR.'/SforcePartnerClient.php');
require_once (SOAP_CLIENT_BASEDIR.'/SforceHeaderOptions.php');
require_once ('../userAuth.php');

try {
  $mySforceConnection = new SforcePartnerClient();
  $mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/partner.wsdl.xml');
  $mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);

  $fields = array (
    'FirstName' => 'John',
    'LastName' => 'Smith',
    'Phone' => '510-555-5555',
    'BirthDate' => '1950-01-01'
  );

  $sObject = new SObject();
  $sObject->fields = $fields;
  $sObject->type = 'Contact';

  $sObject2 = new SObject();
  $sObject2->fields = $fields;
  $sObject2->type = 'Contact';

  echo "**** Creating the following:\r\n";
  $createResponse = $mySforceConnection->create(array($sObject, $sObject2));

  print_r($createResponse);

  $ids = array();
  foreach ($createResponse as $createResult) {
    print_r($createResult);
    array_push($ids, $createResult->id);
  }
  echo "**** Now for Delete:\r\n";
  $deleteResult = $mySforceConnection->delete($ids);
  print_r($deleteResult);

  echo "**** Now for UnDelete:\r\n";
  $deleteResult = $mySforceConnection->undelete($ids);
  print_r($deleteResult);
} catch (Exception $e) {
  echo $mySforceConnection->getLastRequest();
  echo $e->faultstring;
}
?>