1. Go to this page and download the library: Download 10quality/salsa-api-php 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/ */
10quality / salsa-api-php example snippets
use Salsa\Api;
$api = Api::instance([
'token' => '..YOUR-ACCESS-TOKEN..',
'env' => 'live', // For development change to 'sandbox'
'sandbox' => 'https://sandbox.salsalabs.com/' // Sandbox environment custom base URL.
]);
use Salsa\Metrics;
$endpoint = new Metrics($api);
// Retrieve metrics response
$response = $endpoint->get();
// A specific metric
echo $endpoint->get()->payload->totalAPICalls;
use Salsa\Supporters;
$endpoint = new Supporters($api);
// Search for supporters
$response = $endpoint->searchByEmail('[email protected]');
$response = $endpoint->searchByEmails(['[email protected]', '[email protected]']);
// Retrieve supporters from response
print_r($response->supporters);
use Salsa\Supporters;
use Salsa\Models\Supporter;
// Define the endpoint
$endpoint = new Supporters($api);
// Create supporter using model
$supporter = new Supporter;
$supporter->email = '[email protected]';
$supporter->title = 'Mr';
$supporter->firstName = 'Alejandro';
$supporter->lastName = 'Mostajo';
$supporter->address = [
'line1' => 'Alice in wonderland',
'line2' => 'In the books',
'city' => 'San Diego',
'state' => 'CA',
'postalCode' => '99999',
'county' => 'CA',
'country' => 'US',
];
$supporter->dateOfBirth = '2017-01-01';
// Phones
$supporter->cellphone = '1234567890';
$supporter->workphone = '1234567890';
$supporter->homephone = '1234567890';
// Custom fields
$supporter->addCustomField(
null, // Field ID
'Nickname', // Field Name
'Piru', // Value
null // Type
);
// Add supporter
$response = $endpoint->update($supporter);
// Get updated supporters with their Salsa Supporter ID
$response->supporters;
// Add multiple supporters
$response = $endpoint->updateBatch([$supporter, $supporter2]);
use Salsa\Supporters;
use Salsa\Models\Supporter;
// Define the endpoint
$endpoint = new Supporters($api);
// Create supporter using model
$supporter = new Supporter;
$supporter->supporterId = '-an-id-';
// Delete supporter
$response = $endpoint->delete($supporter);
// Delete multiple supporters
$response = $endpoint->deleteBatch([$supporter, $supporter2]);
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.