Skip to Content

TheBlogReaders.com

Salesforce.com, PHP, MySQL, Javascript, Ajax, Htacces

SEARCH the Salesforce data using PHP

Be First!
by January 25, 2013 PHP, SALESFORCE

SEARCH the Salesforce data using PHP

<?php
ini_set(“soap.wsdl_cache_enabled”, “0″);

// PHP Tool Kit class scripts to login to Salesforce Org
require_once (‘../includes/soapclient/SforcePartnerClient.php’);
require_once (‘../includes/soapclient/SforceHeaderOptions.php’);

// Salesforce Login information
$wsdl = ‘partner.wsdl.xml’;    // PARTNER WSDL FILE PATH
$userName = “salesforce username”;
$password = “salesforce password”; // PASSWORD SHOULD BE COMBINATION OF “PASSWORD + SECURITY TOKEN”, if it’s a Developer ORG.

// Process of logging on and getting a salesforce.com session
$client = new SforcePartnerClient();
$client->createConnection($wsdl);
$loginResult = $client->login($userName, $password);

//Then perform to Search Your Salesforce Data

$search = ‘FIND {415*} IN PHONE FIELDS ‘.
‘RETURNING CONTACT(ID, PHONE, FIRSTNAME, LASTNAME), ‘.
‘LEAD(ID, PHONE, FIRSTNAME, LASTNAME), ‘.
‘ACCOUNT(ID, PHONE, NAME)’;
$searchResult = $loginResult->search($search);

print_r($searchResult);
} catch (Exception $e) {
print_r($loginResult->getLastRequest());
echo $e->faultstring;
}
?>

(558)

Previous
Next

Leave a Reply