PHP code example of luketowers / php-donorperfect-api

1. Go to this page and download the library: Download luketowers/php-donorperfect-api 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/ */

    

luketowers / php-donorperfect-api example snippets


use LukeTowers\DonorPerfectPHP\DonorPerfect;

// Initialize the client with an API key and app name (max 20 characters)
$api = new DonorPerfect('my_api_key_here', 'NameOfMyApp');

// Initialize the client with a user login and password and app name (max 20 characters)
$api = new DonorPerfect(['login' => 'MyUsername', 'pass' => 'MyPassword'], 'NameOfMyApp');

// Call one of the predefined DP actions
$result = $api->dp_donorsearch(['donor_id' => 1]);

// Call a predefined DP action not yet implemented in this library
$result = $api->call('dp_actionname', DonorPerfect::prepareParams(['donor_id' => 1], $arrayOfParamConfigsExpected));

$pageStart = 1;
$pageEnd = 500;

// Run a custom MS SQL statement through the API
$result = $api->callSql("
    SELECT
        *
    FROM (
        SELECT
            ROW_NUMBER() OVER(ORDER BY dp.donor_id ASC) AS row_number,
            dp.donor_id,
            dp.first_name,
            dp.middle_name,
            dp.last_name,
            dp.email,
            dp.address,
            dp.address2,
            dp.city,
            dp.state,
            dp.zip,
            dp.country,
            dp.gift_total
        FROM dp
        LEFT JOIN dpudf ON dpudf.donor_id = dp.donor_id
        WHERE
            (dp.nomail_reason != 'IA'
            AND dp.nomail_reason != 'DE')
            OR dp.nomail_reason IS NULL
    ) AS tmp
    WHERE tmp.row_number BETWEEN {$pageStart} AND {$pageEnd}
");