1. Go to this page and download the library: Download wakeonweb/salesforce-client 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/ */
wakeonweb / salesforce-client example snippets
use WakeOnWeb\SalesforceClient\REST;
use WakeOnWeb\SalesforceClient\ClientInterface;
$client = new REST\Client(
new REST\Gateway('https://cs81.salesforce.com', '41.0'),
new REST\GrantType\PasswordStrategy(
'consumer_key',
'consumer_secret',
'login',
'password',
'security_token'
)
);
try {
$salesforceObject = $client->getObject( 'Account', '1337ID')); // all fields
} catch (\WakeOnWeb\SalesforceClient\Exception\NotFoundException) {
// this object does not exist, do a specifig thing.
}
//$salesforceObject->getAttributes();
//$salesforceObject->getFields();
//$client->getObject( 'Account', '1337ID', ['Name', 'OwnerId', 'CreatedAt'] )); // specific fields
// creation will be a SalesforceObjectCreationObject
$creation = $client->createObject( 'Account', ['name' => 'Chuck Norrs'] );
// $creation->getId();
// $creation->isSuccess();
// $creation->getErrors();
// $creation->getWarnings();
// creation will be a SalesforceObjectCreationObjectResults
$client->searchSOQL('SELECT name from Account'); // NOT_ALL by default.
$client->searchSOQL('SELECT name from Account', ClientInterface::ALL);
// $creation->getTotalSize();
// $creation->isDone();
// $creation->getRecords();