PHPackages                             faixan23/constantcontact - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. faixan23/constantcontact

ActiveLibrary[API Development](/categories/api)

faixan23/constantcontact
========================

Object Oriented Wrapper for Constant Contact API V3 for PHP 7.2

0952↓33.3%PHP

Since May 15Pushed 2y agoCompare

[ Source](https://github.com/faixan23/ConstantContact)[ Packagist](https://packagist.org/packages/faixan23/constantcontact)[ RSS](/packages/faixan23-constantcontact/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

ConstantContact [![Tests](https://github.com/phpfui/ConstantContact/actions/workflows/tests.yml/badge.svg)](https://github.com/phpfui/ConstantContact/actions?query=workflow%3Atests) [![Latest Packagist release](https://camo.githubusercontent.com/f2198475eb976ed5e711ae44b711e58d558e3cd34c7436534e47344a148f03c3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068706675692f636f6e7374616e74636f6e746163742e737667)](https://packagist.org/packages/phpfui/constantcontact) [![](https://camo.githubusercontent.com/7a8a54e7ee075f9a33edda53b4e146cabdd7b14478a2ca64d17080aaff0f3b3d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230352d627269676874677265656e2e7376673f7374796c653d666c6174)](https://camo.githubusercontent.com/7a8a54e7ee075f9a33edda53b4e146cabdd7b14478a2ca64d17080aaff0f3b3d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230352d627269676874677265656e2e7376673f7374796c653d666c6174)
================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#constantcontact---)

PHP Object Oriented wrapper for the Constant Contact V3 API.

**PHPFUI/ConstantContact** is a [modern](#php-versions) PHP library that tracks the latest changes to the Constant Contact API.

**PHPFUI/ConstantContact** reads the [YAML](https://api.cc.email/v3/swagger.yaml) file from the Constant Contact documentation and generates PHP classes directly from the YAML file. The library is auto updated nightly. This means the library is always up to date with the latest changes. See the [versioning](#Versioning) section for further details.

Installation
------------

[](#installation)

Since this library is constantly updated when Constant Contact updates their API, it is best to modify the Composer version constraint from '^' to '&gt;=', for example:

```
"phpfui/constantcontact": "^22.3",

```

should be changed to:

```
"phpfui/constantcontact": ">=22.3",

```

Requirements
------------

[](#requirements)

This library requires PHP Session support for authentication. See [PHP Manual](https://www.php.net/manual/en/session.security.php) and [a good best practices article](https://www.phparch.com/2018/01/php-sessions-in-depth/). You can provide your own session management by specifying a callback with **setSessionCallback**.

Namespaces
----------

[](#namespaces)

This library normalizes the [Constant Contact API](https://v3.developer.constantcontact.com/api_guide/index.html) to modern PHP class standards. All endpoints are first character capitialized. Underscores are removed and followed by a capital letter. Each end point is a class with methods matching the standard REST methods (ie. put, post, delete, put, etc.). The methods take required and optional parameters matching the name specified in the Constant Contact YAML API. In addition, this library supports all definitions of types in the API. See below.

Due to a mistake in naming conventions by Constant Contact API designers, several end points are duplicated between the end point that returns all objects, and the end point that just works with one object. Normally this is dealt with by using the singular form of the noun for CRUD type operations on a single object, and the plural noun form returns a list of objects. This library follows the correct naming convention (single nouns for CRUD and plural nouns for collections) and not the Constant Contact naming convention.

Definitions
-----------

[](#definitions)

This Constant Contact API defines all types of objects to interact with the API. They are defined in the **PHPFUI\\ConstantContact\\Definition** namespace. Only valid fields are allowed to be accessed. Types are fully validated as to the best ability of PHP. Min and max lengths are enforced for strings.

Usage Once Authorized (see below)
---------------------------------

[](#usage-once-authorized-see-below)

```
// Create a client
$client = new \PHPFUI\ConstantContact\Client($apiKey, $secret, $redirectURI);
// Set access and refresh tokens on client
$client->accessToken = $accessTokenFromDatabase;
$client->refreshToken = $refreshTokenFromDatabase;
// Refresh the tokens.  This should be done on a regular (daily) basis so the token does not expire.
$client->refreshToken();
// save $client->accessToken and $client->refreshToken to database.

// $client is now ready to use
$listEndPoint = new \PHPFUI\ConstantContact\V3\ContactLists($client);
$lists = $listEndPoint->get();
do {
  print_r($lists);
  $lists = $listEndPoint->next();
} while ($lists);
```

Constant Contact Setup
----------------------

[](#constant-contact-setup)

In order to use this library, you will need to set up Constant Contact correctly. Go to [Constant Contact API](https://app.constantcontact.com) and create an application. Get an *API Key* and *Secret* and save it off for the **\\PHPFUI\\ConstantContact\\Client** constructor. You will also need to set up and add a *Redirect URI*. You can use  if you want to authorize manually, but it is recommended to allow your users to authorize directly. The *Redirect URI* will receive a code that you will need to authorize the app, and then store the generated access token and refresh token. You should also provide the URL to your site's App logo. This will be shown to your user when they authenticate the app. They will need to sign into Constant Contact if they have not already done so. Fill out the other information as appropriate, but it is for informational purposes only.

Authorization Control Flow
--------------------------

[](#authorization-control-flow)

You will need to set up a web page where your user can enter the *API Key* and *Secret*. You should also provide an **"Authorize"** button if the API returns an error, meaning it was not authorized. This allows the user to control the authorization process. Authorization needs to be done interactively. The user will have to log in to Constant Contact and then authorize the application. Once this is done, the app can run in the background and refresh the token daily and it should not expire or need to be reauthorized as long as the Secret has not been changed. Change the secret to require reauthorization.

The Authorization control flow is as follows:
---------------------------------------------

[](#the-authorization-control-flow-is-as-follows)

### 1. Create A Client and Redirect to Authorization URL

[](#1-create-a-client-and-redirect-to-authorization-url)

```
$redirectURI = 'http://yourdomain/php_script_in_step2.php';
$client = new \PHPFUI\ConstantContact\Client($apiKey, $secret, $redirectURI);
// set any scopes here, defaults to all scopes. Your user will need to accept what ever scopes you specify.
\header('location: ' . $client->getAuthorizationURL());
```

The above will ask the user to authorize the app for the scopes you specified. The default is all scopes, but you can specify different scopes after constructing the client and before you authorize.

### 2. Retrieve the Code sent to the $redirectURI

[](#2-retrieve-the-code-sent-to-the-redirecturi)

```
$client->acquireAccessToken($_GET);
// Save $client->accessToken and $client->refreshToken to the database
// redirect back to your businesss logic (Step 3)
```

You have now recieved authorization to access the API according to the scopes you requested.

### 3. Use in your code

[](#3-use-in-your-code)

```
$client = new \PHPFUI\ConstantContact\Client($apiKey, $secret, $redirectURI);
$client->accessToken = $accessTokenFromDatabase;
$client->refreshToken = $refreshTokenFromDatabase;
$listEndPoint = new \PHPFUI\ConstantContact\V3\ContactLists($client);
$lists = $listEndPoint->get();
do {
  print_r($lists);
  $lists = $listEndPoint->next();
} while ($lists);
```

You can now access the API with the scopes you requested.

### 4. Refresh the token on a regular basis

[](#4-refresh-the-token-on-a-regular-basis)

```
$client->refreshToken();
// save $client->accessToken and $client->refreshToken to database.
```

The token will expire requiring your user to reauthorize your app unless you refresh the token. You should refresh the token on a regular basis to avoid reauthorization.

Versioning
----------

[](#versioning)

Since the [Constant Contact API](https://v3.developer.constantcontact.com/api_guide/index.html) is constantly being updated, this library will track all updates on a calendar based versioning schema. The major version will be the last two digits of the year the update was released. The minor version will be the month it was released. Any bug fixes will be a patch version. So V21.8.0 would be the first August 2021 version, and V21.8.1 would be a bug fix to V21.8. All bug fixes will be included in subsequent versions, so V21.9.0 would include all fixes from the V21.8 version. YAML changes are tracked nightly and a new version will be generated automatically. Multiple YAML changes in a month will be tracked as patch versions.

Full Class Documentation
------------------------

[](#full-class-documentation)

[PHPFUI/InstaDoc](http://www.phpfui.com/?n=PHPFUI%5CConstantContact)

License
-------

[](#license)

**PHPFUI/ConstantContact** is distributed under the MIT License.

### PHP Versions

[](#php-versions)

This library only supports PHP 8.0 and higher versions of PHP. While we would love to support PHP from the late Ming Dynasty, the advantages of modern PHP versions far out weigh quaint notions of backward compatibility. Time to upgrade.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 Bus Factor1

Top contributor holds 84.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/43760911?v=4)[faizan.sh](/maintainers/faixan23)[@faixan23](https://github.com/faixan23)

---

Top Contributors

[![phpfui](https://avatars.githubusercontent.com/u/7434059?v=4)](https://github.com/phpfui "phpfui (78 commits)")[![faixan23](https://avatars.githubusercontent.com/u/43760911?v=4)](https://github.com/faixan23 "faixan23 (7 commits)")[![pamekar](https://avatars.githubusercontent.com/u/24904288?v=4)](https://github.com/pamekar "pamekar (7 commits)")

### Embed Badge

![Health badge](/badges/faixan23-constantcontact/health.svg)

```
[![Health](https://phpackages.com/badges/faixan23-constantcontact/health.svg)](https://phpackages.com/packages/faixan23-constantcontact)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M475](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M270](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[microsoft/microsoft-graph

The Microsoft Graph SDK for PHP

65723.5M95](/packages/microsoft-microsoft-graph)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
