PHP code example of playable-cn / forrest
1. Go to this page and download the library: Download playable-cn/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/ */
playable-cn / forrest example snippets
"omniphx/forrest": "2.*"
Omniphx\Forrest\Providers\Laravel\ForrestServiceProvider::class
'Forrest' => Omniphx\Forrest\Providers\Laravel\Facades\Forrest::class
class_alias('Omniphx\Forrest\Providers\Laravel\Facades\Forrest', 'Forrest');
$app->register(Omniphx\Forrest\Providers\Lumen\ForrestServiceProvider::class);
$app->configure('forrest');
$app->withFacades();
Route::get('/authenticate', function()
{
return Forrest::authenticate();
});
Route::get('/callback', function()
{
Forrest::callback();
return Redirect::to('/');
});
Route::get('/authenticate', function()
{
Forrest::authenticate();
return Redirect::to('/');
});
Route::get('/authenticate', function()
{
Forrest::authenticate();
return Redirect::to('/');
});
Route::Post('/authenticate', function(Request $request)
{
Forrest::authenticateUser('https://login.salesforce.com',$request->username, $request->password);
return Redirect::to('/');
});
Route::get('/authenticate', function()
{
$loginURL = 'https://test.salesforce.com';
return Forrest::authenticate($loginURL);
});
Forrest::query('SELECT Id FROM Account');
Forrest::sobjects('Account',[
'method' => 'post',
'body' => ['Name' => 'Dunder Mifflin']
]);
Forrest::sobjects('Account/001i000000xxx',[
'method' => 'put',
'body' => [
'Name' => 'Dunder Mifflin',
'Phone' => '555-555-5555'
]
]);
$externalId = 'XYZ1234';
Forrest::sobjects('Account/External_Id__c/' + $externalId, [
'method' => 'patch',
'body' => [
'Name' => 'Dunder Mifflin',
'Phone' => '555-555-5555'
]
]);
Forrest::sobjects('Account/001i000000xxx', ['method' => 'delete']);
Forrest::sobjects('Lead',[
'method' => 'post',
'body' => [
'Company' => 'Dunder Mifflin',
'LastName' => 'Scott'
],
'headers' => [
'Sforce-Auto-Assign' => '01Q1N000000yMQZUA2'
]
]);
Forrest::sobjects('Account',['format'=>'xml']);
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']);
$bulkJob = Forrest::jobs('ingest', [
'method' => 'post',
'body' => [
"object" => "Contact",
"externalIdFieldName" => "externalId",
"contentType" => "CSV",
"operation" => "upsert"
]
]);
Forrest::jobs('ingest/' . $bulkJob['id'] . '/batches', [
'method' => 'put',
'headers' => [
'Content-Type' => 'text/csv'
],
'body' => $csv
]);
$response = Forrest::jobs('ingest/' . $bulkJob['id'] . '/', [
'method' => 'patch',
'body' => [
"state" => "UploadComplete"
]
]);
Forrest::refresh();
Forrest::revoke();
Forrest::versions();
Forrest::resources();
Forrest::identity();
Forrest::custom('/myEndpoint');
Forrest::custom('/myEndpoint', [
'method' => 'post',
'body' => ['foo' => 'bar'],
'parameters' => ['flim' => 'flam']]);
Forrest::get('/services/data/v20.0/endpoint');
Forrest::head('/services/data/v20.0/endpoint');
Forrest::post('/services/data/v20.0/endpoint', ['my'=>'param']);
Forrest::put('/services/data/v20.0/endpoint', ['my'=>'param']);
Forrest::patch('/services/data/v20.0/endpoint', ['my'=>'param']);
Forrest::delete('/services/data/v20.0/endpoint');
$response = Forrest::sobjects($resource, ['format'=> 'none']);
$content = (string) $response->getBody(); // Guzzle response
Event::listen('forrest.response', function($request, $response) {
dd((string) $response);
});
bash
php artisan vendor:publish