dev-master
9999999-dev https://github.com/diimpp/salesforce-rest-apiExperimental Salesforce rest & bulk api
MIT
The Requires
- php >=5.3.0
- guzzlehttp/guzzle ~6
by Dmitri Perunov
api rest salesforce bulk
Experimental Salesforce rest & bulk api
Experimental Salesforce REST and Bulk API implementation, that designed in fashion of facebook php ads sdk., (*1)
Currently supports only bulk requests partially., (*2)
composer.phar require diimpp/salesforce-rest-api
$api = \Diimpp\Salesforce\Api::init($accessToken, $instanceUrl); // or // $api = \Diimpp\Salesforce\Api::initWithAuthentication($clientId, $clientSecret, $username, $password); // Example usage of bulk api query. $job = new Job($api); $job->create([ 'operation' => Job::OPERATION_QUERY, 'object' => 'Contact', 'contentType' => Job::CONTENT_TYPE_XML ]); $soql = 'select id, lastname, firstname, salutation, name from Contact'; $jobBatch = new JobBatch($job, $api); $jobBatch->create(['body' => $soql]); $job->close(); // Wait till job batch will be completed. while (JobBatch::STATE_QUEUED === $jobBatch->state || JobBatch::STATE_IN_PROGRESS === $jobBatch->state) { $jobBatch->read(); } if (JobBatch::STATE_COMPLETED !== $jobBatch->state) { throw new \RuntimeException(sprintf('Salesforce Job Batch request failed with reason: %s', print_r($jobBatch->getData(), true))); } $jobBatchResult = new JobBatchResult($jobBatch); $jobBatchResult->read(); // Salesforce API returns either ID as string or array of IDs of batch results. if (is_string($jobBatchResult->result)) { $data = $jobBatchResult->retrieveData($jobBatchResult->result)); } elseif (is_array($jobBatchResult->result)) { foreach ($jobBatchResult->result as $resultId) { $data[] = $jobBatchResult->retrieveData($resultId)); } }
Patches and use cases are most welcome., (*3)
Experimental Salesforce rest & bulk api
MIT
api rest salesforce bulk