The Client class needs to store authentication information between PHP sessions in order to function correctly. The class defaults to normal PHP $_SESSION handling, but you can specify a callback via setSessionCallback to provide a different persistence model. The callback function signature is:
- param string $key used to store or retrieve $value
- param ?string $value if null, value should be returned and key deleted, if not null, value should be stored by key.
- return string $value from store or value passed in on set (ignored)
Properties |
public string $accessToken = '' |
public bool $PKCE |
public string $refreshToken = '' |
Methods |
public __construct(string $clientAPIKey, string $clientSecret, string $redirectURI, bool $PKCE = true) Construct a client. By default, all scopes are enabled. You can remove any, or set new ones. |
public acquireAccessToken(array $parameters) : bool Exchange an authorization code for an access token. Make this call by passing in the code present when the account owner is redirected back to you. The response will contain an 'access_token' and 'refresh_token'
|
public addScope(string $scope) : self |
public delete(string $url) : bool Issue a delete request. This is not normally called directly, but by the V3 namespace classes. |
public get(string $url, array $parameters) : array Issue a get request. This is not normally called directly, but by the V3 namespace classes. |
public getAuthorizationURL() : string Generate the URL an account owner would use to allow your app to access their account. After visiting the URL, the account owner is prompted to log in and allow your app to access their account. They are then redirected to your redirect URL with the authorization code appended as a query parameter. e.g.: http://localhost:8888/?code={authorization_code} |
public getBody() : string |
public getLastError() : string |
public getStatusCode() : int |
public next() : array Get the next result set
|
public patch(string $url, array $parameters) : array Issue a patch request. This is not normally called directly, but by the V3 namespace classes. |
public post(string $url, array $parameters) : array Issue a post request. This is not normally called directly, but by the V3 namespace classes. |
public put(string $url, array $parameters, string $method = 'PUT') : array Issue a put request. This is not normally called directly, but by the V3 namespace classes. |
public refreshToken() : bool Refresh the access token. |
public removeScope(string $scope) : self |
public setHost(string $host) : self |
public setScopes(array $scopes) : self |
public setSessionCallback(callable $callback) : self To avoid using built in PHP Sessions, set the callback to save values yourself Callback function signature:
|
Properties |
private string $authorizeURL = 'https://authz.constantcontact.com/oauth2/default/v1/authorize' |
private string $body = '' |
private string $clientAPIKey |
private string $clientSecret |
private GuzzleHttp |
private string $host = '' |
private string $lastError = '' |
private string $next = '' |
private string $oauth2URL = 'https://authz.constantcontact.com/oauth2/default/v1/token' |
private string $redirectURI |
private array $scopes = [] |
private $sessionCallback = NULL |
private int $statusCode = 200 |
private array $validScopes = ['account_read', 'account_update', 'contact_data', 'campaign_data', 'offline_access'] |
Methods |
private base64url_encode(string $data) : string |
private codeChallenge(?string $code_verifier = NULL) : array Generate code_verifier and code_challenge for rfc7636 PKCE.
|
private exec(CurlHandle $ch) : bool |
private getHeaders(array $additional = []) : array |
private process(Psr\Http\Message\ResponseInterface $response) : array |
private session(string $key, ?string $value) : string |
private setAuthorization(CurlHandle $ch) : void |