Again there was some discrepancies with your script and it is so much easier and better to use the partner WSDL file.
I did get it to work on my developers org > http://www.mikesimonds.com/salesforce/upsert.php
Here is your modified code using the partner client:
PHP Code:
<?php
ini_set("soap.wsdl_cache_enabled", "0");
require_once ('/home/mike/public_html/salesforce/soapclient/SforcePartnerClient.php');
$cr = "\n";
$sf_option = array('username' => 'sportsrant2002@yahoo.com',
'password' => 'mas=1212',
'security-token' => 'UjhgAORkjgLp0dCztejrKu2X', );
$sf = new SforcePartnerClient();
$soap_client = $sf->createConnection('/home/mike/public_html/salesforce/soapclient/partner.wsdl.xml');
try
{
$sf_login = $sf->login($sf_option['username'], $sf_option['password'] . $sf_option['security-token']);
}
catch (exception $e)
{
$sf_login = null;
echo 'Salesforce Login Error' . $cr;
echo $e->faultstring;
}
$data = array();
$row = array ( 'Name' => 'beta_one',
'Called__c' => '9051234567',
'Caller__c' => '9995551212'
);
array_push($data, $row);
$row = array ( 'Name' => 'beta_two',
'Called__c' => '9051235555',
'Caller__c' => '4164443333'
);
array_push($data, $row);
$sObjects = array();
foreach ($data as $row)
{
$sObject = new sObject();
$sObject->type = 'Calls__c';
$sObject->fields = $row;
array_push($sObjects, $sObject);
}
echo '<pre>' . print_r($sObjects, true) . '</pre>';
//exit;
try
{
$result = $sf->upsert('Name', $sObjects);
}
catch (exception $e)
{
$result = null;
echo 'Salesforce Upsert Error' . $cr;
echo '<pre>' . print_r($e, true) . '</pre>';
}
echo '<pre>' . print_r($result, true) . '</pre>';
?>
You can login to my salesforce org using the credentials that are located in the code above
let me know if you can get this working, you should be able too
Hope that helps!!
~Mike
Bookmarks