You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-16Lines changed: 28 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -16,10 +16,8 @@ should be changed to:
16
16
"phpfui/constantcontact": ">=22.3",
17
17
```
18
18
19
-
## New OAuth2 PKCE Authentication effective April 1, 2022
20
-
As of March 31, 2022, Constant Contact will no longer be supporting versions of this library before 22.3. You must upgrade you app on the Constant Contact site. A new secret is also suggested. You must also upgrade to the 22.3 version of this library. The only code change needed is to pass the parameter array ($_GET) to acquireAccessToken instead of the single code parameter.
21
-
22
-
This library now 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**.
19
+
## Requirements
20
+
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**.
23
21
24
22
## Namespaces
25
23
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.
@@ -57,29 +55,43 @@ You will need to set up a web page where your user can enter the *API Key* and *
57
55
58
56
## The Authorization control flow is as follows:
59
57
60
-
1. Create a Client with the API Key and Secret and specify a Redirect URI which will receive a code from Constant Contact.
61
-
2. Redirect to $client->getAuthorizationURL(); User will authorize and redirected back to the $redirectURI you provide.
62
-
3. Retrieve the code and save access and refresh tokens for later use. Redirect back to where ever.
63
-
64
-
### 1. Create A Client
58
+
### 1. Create A Client and Redirect to Authorization URL
65
59
```php
66
-
$client = new \PHPFUI\ConstantContact\Client($apiKey, $secret, $tokenURL);
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.
74
66
75
-
### 3. Retrieve the Code sent to the $redirectURI
67
+
### 2. Retrieve the Code sent to the $redirectURI
76
68
```php
77
69
$client->acquireAccessToken($_GET);
78
70
// Save $client->accessToken and $client->refreshToken to the database
79
-
// redirect back to where ever
71
+
// redirect back to your businesss logic (Step 3)
80
72
```
73
+
You have now recieved authorization to access the API according to the scopes you requested.
81
74
82
-
You should now be authorized to use the API. Make sure you save and restore the access token and refresh tokens every time you access the API.
75
+
### 3. Use in your code
76
+
```php
77
+
$client = new \PHPFUI\ConstantContact\Client($apiKey, $secret, $redirectURI);
$listEndPoint = new \PHPFUI\ConstantContact\V3\ContactLists($client);
81
+
$lists = $listEndPoint->get();
82
+
do {
83
+
print_r($lists);
84
+
$lists = $listEndPoint->next();
85
+
} while ($lists);
86
+
```
87
+
You can now access the API with the scopes you requested.
88
+
89
+
### 4. Refresh the token on a regular basis
90
+
```php
91
+
$client->refreshToken();
92
+
// save $client->accessToken and $client->refreshToken to database.
93
+
```
94
+
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.
83
95
84
96
## Versioning
85
97
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.
0 commit comments