PHP code example of pithstudio / forrest

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

    

pithstudio / forrest example snippets


Route::get('/authenticate', function()
{
    return Forrest::authenticate();
});

Route::get('/callback', function()
{
    Forrest::callback();

    $url = Config::get('forrest::authRedirect');

    return Redirect::to($url);
});

Route::get('/authenticate', function()
{
    Forrest::authenticate();

    $url = Config::get('forrest::authRedirect');

    return Redirect::to($url);
});

Route::get('/authenticate', function()
{
    $loginURL = 'https://test.salesforce.com';

    return Forrest::authenticate($loginURL);
});

Forrest::query('SELECT Id FROM Account');

$body = ['Name' => 'New Account'];
Forrest::sobjects('Account',[
    'method' => 'post',
    'body'   => $body]);

$body = [
    'Name'  => 'Acme'
    'Phone' => '555-555-5555'];

Forrest::sobjects('Account/001i000000xxx',[
    'method' => 'put',
    'body'   => $body]);

$body = [
    'Phone' => '555-555-5555',
    'External_Id__c' => 'XYZ1234'];

Forrest::sobjects('Account',[
    'method' => 'patch',
    'body'   => $body]);

Forrest::sobjects('Account/001i000000xxx', ['method' => 'delete']);

Forrest::describe('Account',['format'=>'xml']);

Session::get('resources');

Forrest::resources();

Array
(
    [sobjects] => /services/data/v30.0/sobjects
    [connect] => /services/data/v30.0/connect
    [query] => /services/data/v30.0/query
    [theme] => /services/data/v30.0/theme
    [queryAll] => /services/data/v30.0/queryAll
    [tooling] => /services/data/v30.0/tooling
    [chatter] => /services/data/v30.0/chatter
    [analytics] => /services/data/v30.0/analytics
    [recent] => /services/data/v30.0/recent
    [process] => /services/data/v30.0/process
    [identity] => https://login.salesforce.com/id/00Di0000000XXXXXX/005i0000000aaaaAAA
    [flexiPage] => /services/data/v30.0/flexiPage
    [search] => /services/data/v30.0/search
    [quickActions] => /services/data/v30.0/quickActions
    [appMenu] => /services/data/v30.0/appMenu
)

Forrest::theme();

Forrest::appMenu();

Forrest::sobjects('Account/describe/approvalLayouts/');

Forrest::theme(['format'=>'xml']);

Forrest::refresh();

Forrest::revoke();

Forrest::versions();

Forrest::resources();

Forrest::identity();

Forrest::limits();

Forrest::describe();

Forrest::query('SELECT Id FROM Account');

Forrest::queryExplain('SELECT Id FROM Account');

Forrest::queryAll('SELECT Id FROM Account');

Forrest::search('Find {foo}');

Forrest::scopeOrder();

Forrest::searchLayouts('Account,Contact,Lead');

Forrest::suggestedArticles('foo', [
    'parameters' => [
        'channel' => 'App',
        'publishStatus' => 'Draft']]);

Forrest::suggestedQueries('app, [
    'parameters' => ['foo' => 'bar']]);

Forrest::custom('/myEndpoint');

Forrest::custom('/myEndpoint', [
    'method' => 'post',
    'body' => ['foo' => 'bar'],
    'parameters' => ['flim' => 'flam']]);
bash
php artisan config:publish omniphx/forrest