PHP code example of ehaerer / php-salesforce-rest-api

1. Go to this page and download the library: Download ehaerer/php-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/ */

    

ehaerer / php-salesforce-rest-api example snippets

bjsmasth/php-salesforce-rest-api
Cleeng/php-salesforce-rest-api
jerkob/php-salesforce-rest-api-forked
bash
    $query = 'SELECT Id,Name FROM ACCOUNT LIMIT 100';

    $additionalHeaders = ['key' => 'value'];

    /* returns array with the queried data */
    $data = $salesforceFunctions->query($query, $additionalHeaders);

bash

    $data = [
       'Name' => 'Some name',
    ];
    $additionalHeaders = ['key' => 'value'];

    /* returns the id of the created object or full response */
    $accountId = $salesforceFunctions->create('Account', $data, $additionalHeaders);
    $fullResponse = $salesforceFunctions->create('Account', $data, $additionalHeaders, true);
bash
    $newData = [
       'Name' => 'another name',
    ];
    $additionalHeaders = ['key' => 'value'];

    /* returns statuscode */
    $salesforceFunctions->update('Account', $id, $newData, $additionalHeaders);
bash
    $additionalHeaders = ['key' => 'value'];
    $salesforceFunctions->delete('Account', $id, $additionalHeaders);
bash
    $additionalHeaders = ['key' => 'value'];
    $salesforceFunctions->customEndpoint('apex/myCustomEndpoint', $data, 200, $additionalHeaders);