Skip to content

duncanheron/SalesforceRestClient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 

Repository files navigation

Salesforce Rest API

A php class to interact with the Salesforce REST API

Requirements:
Because I find using curl cumbersome I chose to use Guzzle to make my REST requests.

The obvious

use Salesforce\SalesforceBundle\Entity\SalesforceRestClient;
$restClient = new SalesforceRestClient(
	$config,
    new Guzzle\Http\Client
);

Describing a Salesforce object

$object = $restClient->describeObject('Account');

if ($object) {
    print '<pre>' . $object. '</pre>';
}

Retrieving multiple records

$soql = 'SELECT Name, Id from Account LIMIT 10';
$records = $restClient->getRecords($soql);

foreach ($records as $record) {
    print 'Name : ' . $record->Name;
}

Retrieving a single record

$soql = 'SELECT Name, Id from Account LIMIT 1';
$record = $restClient->getRecord($soql);

if ($record) {
    print 'Name : ' . $record->Name;
}

Creating a record

$data = array(
			'LastName' => 'Heron',
			'FirstName' => 'Duncan'
			);

$insertContact = $restClient->createRecord('Contact',$data);

if($insertContact->success) {
	print 'Record created: ' . $insertContact->id;
}

Updating a record

$recordId = 'SOMESALESFORCECONTACTID';
$data = array(
			'LastName' => 'Heron',
			'FirstName' => 'Duncan'
			);

$updateContact = $restClient->updateRecord($recordId,'Contact',$data);

More examples in index file.

Author

Duncan Heron

About

A simple class used to talk to Salesforce via the REST API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages