This is a direct method. Please consider using the dedicated factory functions as described in Initialization by factory.
Example basic initialization with required arguments:
<?php
use Getresponse\Sdk\Client\GetresponseClient;
use Getresponse\Sdk\Client\Handler\CurlRequestHandler;
use Getresponse\Sdk\Environment\GetResponse;
use Getresponse\Sdk\Authentication\ApiKey;
// $apiKey - your GetResponse API Key
$apiKey = 'my_api_key';
$client = new GetresponseClient(
new CurlRequestHandler(),
new GetResponse(),
new ApiKey($apiKey)
);
GetresponseClient
constructor's parameters are:
RequestHandler $requestHandler
,Environment $environment
,AuthenticationProvider $authentication
RequestHandler
- implementation ofRequestHandler
interface, we provide two handlers:CurlRequestHandler
- basic cURL based handler for single requests or sequential multi requestsCurlMultiRequestHandler
- cURL handler with simultaneous requests support. Use this handler for handling big number of requests to speed up the processing, please note maximum number of concurrent request is limited by throttling limits (Refer to API limit and throttling documentation)
Enviroment
implementation - one of the following (depending on your account type):GetResponse
- for Basic, Plus and Professional package usersGetResponseEnterprisePL
- for Enterprise users (ask your Account Manager for details)GetResponseEnterpriseUS
- for Enterprise users (ask your Account Manager for details)
AuthenticationProvider
implementation - we provide:ApiKey
- API Key based authenticationOAuth
- OAuth2 access token base authentication
We strongly suggest you use the dedicated factory methods to initialize the preconfigured client. Depending on your project you can use:
GetresponseClientFactory::createWithApiKey($apiKey)
- returns the client configured for GetResponse environment and the API Key authorization methodGetresponseClientFactory::createEnterprisePLWithApiKey($apiKey, $domain)
- returns the client configured for the Enterprise PL environment and the API Key authorization methodGetresponseClientFactory::createEnterpriseUSWithApiKey($apiKey, $domain)
- returns the client configured for the Enterprise US environment and the API Key authorization methodGetresponseClientFactory::createWithAccessToken($accessToken)
- returns the client configured for the GetResponse environment and the OAuth2 authorization methodGetresponseClientFactory::createEnterprisePLWithAccessToken($accessToken, $domain)
- returns the client configured for the GetResponse Enterprise PL environment and the OAuth2 authorization methodGetresponseClientFactory::createEnterpriseUSWithAccessToken($accessToken, $domain)
- returns the client configured for the GetResponse Enterprise US environment and the OAuth2 authorization method
Below is the list of the available functions:
call($operation)
- calls a single operation and returns the response (ResponseInterface
).callMany($array)
- calls an array of operations, returns an iterable collection of responses. Note the way thecallMany
behavior depends on your RequestHandler:CurlRequestHandler
performs requests sequentially, one by one.CurlMultiRequestHandler
performs requests simultaneously. Maximum number of concurrent request is limited by throttling limits (Read more in API Docs). Please note theMAX_CALLS_LIMIT
constant setting - the array of operations can't exceeds this limit. Otherwise, you will get an exception. Both limits apply.
See "Logging and debugging" section.