Credit goes to this url for this post. I repost in case his site goes down and the info is lost. http://www.mikesimonds.com/adding-event-calendar-t111.html
The object to update or insert a new calendar event is the "Event" object in salesforce
There are 4 required fields that need to be inserted in order for the event to be added to your instance of Salesforce.
Assigned To
Subject
Start (date and time)
End (date and time)
Those API field names are
Owner Id
Subject
StartDateTime
EndDateTime
Remember that Salesforce times are all set to GMT, so you have to account for that. Since my time is set to -6 GMT, I have to adjust my code for that:
PHP Code: <?php ini_set("soap.wsdl_cache_enabled","0"); require_once ('./soapclient/SforcePartnerClient.php'); require_once ('./soapclient/SforceHeaderOptions.php'); $mystuff = array('OwnerId' => '00550000000wI2LAAU', // Assigned To 'Subject' => 'PHP Event Addidtion Test 2', //Subject 'StartDateTime' => '2008-08-05T12:00:00.000Z', //Start time of event 'EndDateTime' => '2008-08-05T13:00:00.000Z'); //End time of event **ALL TIMES ARE GMT, REMEMBER TO ACCOUNT FOR THIS**** //clean User to allow changing of characters to XML $mystuff = array_map('htmlspecialchars',$mystuff); //try to add User from from array try { //salesforce login and wsdl $wsdl = './soapclient/partner.wsdl.xml'; $userName = "me@email.com"; // change this to a valid email $password = "password"; // change this to a valid password //connect to salesforce $client = new SforcePartnerClient(); $client->createConnection($wsdl); $loginResult = $client->login($userName,$password); $sObject = new sObject(); $sObject->type = 'Event'; $sObject->fields = $mystuff; //this part adds the contact to salesforce $result = $client->create(array($sObject)); if ($result->success) { echo "A new Calendar event has been added to your instance of Salesforce with an Id of ".$result->id."
"; echo "**************** ALL DONE ****************
"; exit; } else { $errMessage = $result->errors->message; echo $errMessage; } } catch (exception $e) { // This is reached if there is a major problem in the data or with // the salesforce.com connection. Normal data errors are caught by // salesforce.com echo ''.print_r($e,true).'';
return false;
exit;
}?>