Overview

Namespaces

  • Ctct
    • Auth
    • Components
      • Account
      • Activities
      • Contacts
      • EmailMarketing
      • Tracking
    • Exceptions
    • Services
  • PHP

Classes

  • CtctOAuth2
  • SessionDataStore

Interfaces

  • CtctDataStore
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: namespace Ctct\Auth;
 3: 
 4: use Ctct\Auth\CtctDataStore;
 5: 
 6: /**
 7:  * Example implementation of the CTCTDataStore interface that uses session for access token storage
 8:  *
 9:  * @package     Auth
10:  * @author         Constant Contact
11:  */
12: class SessionDataStore implements CtctDataStore
13: {
14:     public function __construct()
15:     {
16:         session_start();
17:         
18:         if (!isset($_SESSION['datastore'])) {
19:             $_SESSION['datastore'] = array();
20:         }
21:         
22:     }
23:     
24:     /**
25:      * Add a new user to the data store
26:      * @params string $username - Constant Contact username
27:      * @params array $params - additional parameters
28:      */
29:     public function addUser($username, array $params)
30:     {
31:         $_SESSION['datastore'][$username] = $params;
32:     }
33:     
34:     /**
35:      * Get an existing user from the data store
36:      * @params string $username - Constant Contact username
37:      */
38:     public function getUser($username)
39:     {
40:         if (array_key_exists($username, $_SESSION['datastore'])) {
41:             return $_SESSION['datastore'][$username];
42:         } else {
43:             return false;
44:         }
45:     }
46:     
47:     /**
48:      * Update an existing user in the data store
49:      * @params string $username - Constant Contact username
50:      * @params array $params - additional parameters
51:      */
52:     public function updateUser($username, array $params)
53:     {
54:         if (array_key_exists($username, $_SESSION['datastore'])) {
55:             $_SESSION['datastore'][$username] = $params;
56:         }
57:     }
58:     
59:     /**
60:      * Delete an existing user from the data store
61:      * @params string $username - Constant Contact username
62:      */
63:     public function deleteUser ($username)
64:     {
65:         unset($_SESSION['datastore'][$username]);
66:     }
67: }
68: 
Appconnect PHP SDK API documentation generated by ApiGen 2.8.0