Skip to content
PHP Library to easily integrate with AWeber's API
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

AWeber API PHP Library

PHP library for easily integrating with the AWeber API.

Basic Usage:

Refer to demo.php to see a working example of how to authenticate an app and query the API.

For more complete documentation please refer to:

Handling Errors:

Sometimes errors happen and your application should handle them appropriately. Whenever an API error occurs an AWeberAPIException will be raised with a detailed error message and documentation link to explain what is wrong.

You should wrap any calls to the API in a try/except block.

Common Errors:

  • Bad request (400 error)
  • Your application is not authorized (401 error)
  • Your application has been rate limited (403 error)
  • Resource not found (404 error)
  • API Temporarily unavailable (503 error)

Refer to for the complete list

Example Below:


$consumerKey = '***';
$consumerSecret = '***';
$accessKey = '***';
$accessSecret = '***';

$aweber = new AWeberAPI($consumerKey, $consumerSecret);
$account = $aweber->getAccount($accessKey, $accessSecret);

try {
    $resource = $account->loadFromUrl('/accounts/idontexist');
} catch (AWeberAPIException $exc) {
    print "<li> $exc->type on $exc->url, refer to $exc->message for more info ...<br>";


2012-05-08: v1.1.4

   Some API Developers have reported AWeberOAuthDataMissing exceptions when using the demo.php script.
   This error message is not helpful as the typical cause for this exception is an invalid consumer key or secret.

   The client library has been refactored to always raise an AWeberAPIException when a 40x/50x http status code
   response is returned.  This exception will clearly indicate the cause of the error for easier troubleshooting.
  • Refactored makeRequest to always raise an AWeberAPIException when a 40x or 50x status is returned.
  • Refactored makeRequest to indicate transient networking or firewall connectivity issues.
  • Refactored mock adaptor makeRequest for testing to behave the same way as the real makeRequest does.

2012-04-18: v1.1.3

  • Removed usage of deprecated split function.

2011-12-23: v1.1.2

  • Fixed a bug in the AWeberCollection class to properly set the URL of entries found in collections.

2011-10-10: v1.1.1

  • Raise an E_USER_WARNING instead of a fatal error if multiple instances of the client library are installed.

2011-08-29: v1.1.0

  • Modified client library to raise an AWeberAPIException on any API errors (HTTP status >= 400)
  • Refactored tests for better code coverage
  • Refactored move and create methods to return the resource or raise an AWeberAPIException on error.
  • Added getActivity method to a subscriber entry.

Running Tests:

Testing the PHP api library requires installation of a few utilities.


Apache Ant is used to run the build targets in the build.xml file. Get the latest version.

Setup /etc/php.ini configuration file. Make sure include_path contains the correct directories.(/usr/lib/php on MacOS) Set date.timezone to your local timezone.

PHP PEAR is used to install utilities for testing and code metrics. Upgrade to the latest version using sudo pear upgrade pear.

PHP QA Tools contain a collection of PHP testing tools. The following commands were needed to install:

sudo pear upgrade
sudo pear config-set auto_discover 1
sudo pear channel-discover
sudo pear install phpqatools/phpqatools

If installing PHP QA Tools fails due to missing channels, manually add the missing channels:

sudo pear channel-discover
sudo pear channel-discover
sudo pear channel-discover
sudo pear channel-discover
sudo pear channel-discover

Execute Tests

Once the above requirements are installed, run the tests from the base directory using the command: ant phpunit.

To run the entire suite of checks and tests, run: ant.

Something went wrong with that request. Please try again.