PHP code example of mmollick / drip-php

1. Go to this page and download the library: Download mmollick/drip-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/ */

    

mmollick / drip-php example snippets


// Authenticating w/ API key
\MMollick\Drip\Drip::setTokenCredentials($accountId, $api_key)

// Authenticating w/ OAuth access_token
\MMollick\Drip\Drip::setOAuthAccessToken($accountId, $access_token)

// Authentication w/ API Key
$auth = new \MMollick\Drip\Auth($account_id, $api_key);
$drip = new \MMollick\Drip\Request($auth);

// Authentication w/ OAuth access_token
$authUsingOauth = new \MMollick\Drip\Auth($account_id, $access_token, true);
$dripUsingOauth = new \MMollick\Drip\Request($authUsingOauth);

try {
    $drip->getSubscribers();
}
catch (\MMollick\Drip\Errors\AuthException $e) {
    // Authentication failed, check API keys
}
catch (\MMollick\Drip\Errors\ValidationException $e) {
    //The request failed validation, see message or $e->getErrors() for more info
}
catch (\MMollick\Drip\Errors\ApiExceptions $e) {
    // Non-specific API error returned, see message or $e->getErrors() for more info
}
catch (\MMollick\Drip\Errors\RateLimitException $e) {
    // Requests are being throttled, try the request again in a while
}
catch (\MMollick\Drip\Errors\HttpClientException $e) {
    // Most likely a network or Curl related error, see the message for more details
}
catch (\MMollick\Drip\Errors\GeneralException $e) {
    // A generic exception, see message for details
}
catch (\Exception $e) {
    // Catch anything else just for good measure
}
bash
composer