I am trying to delete a single Opportunity within Salesforce using the PHP toolkit. Please can someone tell me if I heading the right direction? I using the ID from the Opportunity to identify the correct record, Is there anything else I need?

Many thanks


include "includes/creds.php";

require_once ('soapclient/SforcePartnerClient.php');
require_once ('soapclient/SforceEnterpriseClient.php');

$mySforceConnection = new SforcePartnerClient();
$mySforceConnection->login(USERNAME, PASSWORD.SECURITY_TOKEN);

$records = array();
$records[0] = new SObject();
$records[0]->fields = array(

    'Id' => '0064J00000Cxpeh'


$records[0]->type = 'Opportunity';

$response = $mySforceConnection->delete($records);

I get the error

Recoverable fatal error: Object of class SObject could not be converted to string in /var/www/thechapar/soapclient/SforceBaseClient.php on line 578

I'm not a salesforce expert, and the code is going to wrong but any help would be great. Thanks again


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.