forked from complex857/salesforce-rest-api-php-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 6
/
examples.sample.php
49 lines (37 loc) · 1.83 KB
/
examples.sample.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
use SalesforceRestAPI;
$salesforce = new SalesforceAPI('https://na17.salesforce.com','32.0','<Consumer Key>', '<Consumer Secret>');
$salesforce->login('<Salesforce Login>','<Salesforce Password>','<Salesforce Security Token>');
$api_versions = $salesforce->getAPIVersions();
$limits = $salesforce->getOrgLimits();
$resource = $salesforce->getAvailableResources();
$objects = $salesforce->getAllObjects();
$date = new DateTime();
$good_metadata = $salesforce->getObjectMetadata('Account');
$good_metadata_all = $salesforce->getObjectMetadata('Account', true);
$good_metadata_since = $salesforce->getObjectMetadata('Account', true, $date);
$bad_metadata = $salesforce->getObjectMetadata('SomeOtherObject');
$create_account = $salesforce->create( 'Account', ['name' => 'New Account'] );
$update_project = $salesforce->update( 'Account', $create_account->id, ['name' => 'Changed'] );
$project = $salesforce->get( 'Account', $create_account->id );
$project_with_fields = $salesforce->get( 'Account', $create_account->id, ['Name', 'OwnerId'] );
$delete_project = $salesforce->delete( 'Account', $create_account->id );
$response = $salesforce->searchSOQL('SELECT name from Position__c',true);
// batch api support
$job = $salesforce->createJob(Job::OPERATION_INSERT, 'Lead', Job::TYPE_JSON);
$users = [
[
'FirstName' => 'jon',
'LastName' => 'doe',
'Phone' => '801-555-2423',
'Email' => '[email protected]',
]
];
$batchInfo = $salesforce->addBatch($job, $users);
$job = $salesforce->closeJob($job);
sleep(10); // wait for salesforce to process the batch
$batchInfo = $salesforce->getBatchInfo($job, $batchInfo);
$batchResult = $salesforce->getBatchResults($job, $batchInfo);
// abort job
$job2 = $salesforce->createJob(Job::OPERATION_INSERT, 'Lead', Job::TYPE_JSON);
$job2 = $salesforce->abortJob($job2);