1. Go to this page and download the library: Download obto/salesforce-rest-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
obto / salesforce-rest-api example snippets
use Obto\Salesforce;
use Obto\Salesforce\Exception;
$authentication = new Salesforce\Authentication\PasswordAuthentication(
"ClientId",
"ClientSecret",
"Username",
"Password",
"SecurityToken"
);
$salesforce = new Salesforce\Client($authentication, "na5");
try {
$contactQueryResults = $salesforce->query("SELECT AccountId, LastName
FROM Contact
WHERE FirstName = ?",
array('Alice')
);
foreach($contactQueryResults as $queryResult) {
print_r($queryResult); // The output of a single record from the query API JSON, converted to associative array
}
$contactQueryResults2 = $salesforce->query("SELECT AccountId, LastName
FROM Contact
WHERE FirstName = :firstName",
array('firstName' => 'Bob')
);
foreach($contactQueryResults2 as $queryResult) {
print_r($queryResult); // The output of a single record from the query API JSON, converted to associative array
}
} catch(Exception\SalesforceNoResults $e) {
// Do something when you have no results from your query
} catch(Exception\Salesforce $e) {
// Error handling
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.