1. Go to this page and download the library: Download fobilow/salesforce 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/ */
$tokenGenerator = new \Crunch\Salesforce\AccessTokenGenerator();
$accessToken = $tokenGenerator->createFromSalesforceResponse($token);
class SFLocalFileStoreConfig implements \Crunch\Salesforce\TokenStore\LocalFileConfigInterface {
/**
* The path where the file will be stored, no trailing slash, must be writable
*
* @return string
*/
public function getFilePath()
{
return __DIR__;
}
}
$tokenStore = new \Crunch\Salesforce\TokenStore\LocalFile(new \Crunch\Salesforce\AccessTokenGenerator, new SFLocalFileStoreConfig);
//Save a token
$tokenStore->saveAccessToken($accessToken);
//Fetch a token
$accessToken = $tokenStore->fetchAccessToken();
$sfConfig = new SalesforceConfig();
$sfClient = new \Crunch\Salesforce\Client($sfConfig, new \GuzzleHttp\Client());
$sfClient->setAccessToken($accessToken);
$data = $sfClient->search('SELECT Email, Name FROM Lead LIMIT 10');