Skip to content

ziming/laravel-get-response

Repository files navigation

A PHP Laravel Library for GetResponse API

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A PHP Laravel library for the GetResponse API v3, built on top of Saloon. It covers the full public API surface — contacts, campaigns (lists), newsletters, autoresponders, SMS, transactional emails, ecommerce (shops, products, orders, carts), automation, statistics and more.

Support

  • Laravel 10.x, 11.x, 12.x, and 13.x

Installation

You can install the package via composer:

composer require ziming/laravel-get-response

You can publish the config file with:

php artisan vendor:publish --tag="laravel-get-response-config"

This is the contents of the published config file:

return [
];

Usage

Create a connector with your API key (find it under Integrations & APIAPI in your GetResponse account) and reach each part of the API through a resource accessor. Every call returns a Saloon Response.

use Ziming\LaravelGetResponse\LaravelGetResponse;

$getResponse = new LaravelGetResponse(config('services.getresponse.token'));

// List contacts (query / sort / fields / pagination are all optional)
$response = $getResponse->contacts()->getContactList(
    queryParameters: ['email' => '@example.com'],
    sortParameters: ['createdOn' => 'DESC'],
    fields: ['contactId', 'email', 'name'],
    perPage: 100,
    page: 1,
);

$contacts = $response->json();

// Create a contact
$getResponse->contacts()->createContact(
    campaign: ['campaignId' => 'AbC12'],
    email: 'jane@example.com',
    name: 'Jane Doe',
);

// Fetch a single contact
$getResponse->contacts()->getContactById(contactId: 'pVyRW');

Authentication

The connector supports both authentication methods documented by GetResponse: API key and OAuth 2.0. API key is the primary method and should be used in most cases.

use Ziming\LaravelGetResponse\LaravelGetResponse;

// API key — sent verbatim in the `X-Auth-Token` header, so it must include the `api-key ` prefix.
$getResponse = new LaravelGetResponse('api-key your-secret-key');
// or, equivalently and more explicitly:
$getResponse = LaravelGetResponse::usingApiKey('api-key your-secret-key');

// OAuth 2.0 — pass the access token (without a prefix); it is sent as `Authorization: Bearer ...`.
$getResponse = LaravelGetResponse::usingOAuth($accessToken);

The package does not perform the OAuth 2.0 authorization flow for you. Obtain the access token with your preferred OAuth client (using the Authorization Code, Client Credentials, Implicit or Refresh Token flow), then hand it to usingOAuth().

GetResponse MAX

GetResponse MAX accounts use a different base URL and must send an X-Domain header on every request. Pass your domain and the matching base URL constant:

use Ziming\LaravelGetResponse\LaravelGetResponse;

// MAX US environment with an API key
$getResponse = LaravelGetResponse::usingApiKey(
    apiKey: 'api-key your-secret-key',
    domain: 'your-company.getresponse360.com',
    baseUrl: LaravelGetResponse::MAX_US_BASE_URL,
);

// MAX PL environment with OAuth 2.0
$getResponse = LaravelGetResponse::usingOAuth(
    accessToken: $accessToken,
    domain: 'your-company.getresponse360.pl',
    baseUrl: LaravelGetResponse::MAX_PL_BASE_URL,
);

Available base URL constants: LaravelGetResponse::BASE_URL (default, non-MAX), LaravelGetResponse::MAX_US_BASE_URL and LaravelGetResponse::MAX_PL_BASE_URL.

Resources mirror the API groups, for example:

$getResponse->campaigns()->getCampaignList();
$getResponse->newsletters()->createNewsletter(/* ... */);
$getResponse->autoresponders()->getAutoresponderList();
$getResponse->tags()->createTag(name: 'VIP', color: '#ff0000');
$getResponse->customFields()->getCustomFieldList();
$getResponse->sms()->sendSms(name: 'Promo', content: 'Hi!', recipientsType: 'contacts');
$getResponse->transactionalEmails()->getTransactionalEmailsList();
$getResponse->shops()->getShopList();
$getResponse->products()->getProductList(shopId: 'shop1');
$getResponse->statistics()->getRevenueStats();
$getResponse->workflows()->updateWorkflow(workflowId: 'w1', status: 'active');

Available resources

abTests(), abTestsSubject(), accounts(), addresses(), autoresponders(), campaigns(), carts(), categories(), clickTracks(), contacts(), customEvents(), customFields(), customReports(), fileLibrary(), forms(), formsAndPopups(), fromFields(), gdprFields(), imports(), landingPages(), legacyForms(), legacyLandingPages(), metaFields(), multimedia(), newsletters(), orders(), predefinedFields(), productVariants(), products(), rssNewsletters(), searchContacts(), shops(), sms(), statistics(), subscriptionConfirmations(), suppressions(), tags(), taxes(), tracking(), transactionalEmailTemplates(), transactionalEmails(), webinars(), websites(), workflows().

You can also send any request object through the connector directly:

use Ziming\LaravelGetResponse\Requests\Contacts\GetContactByIdRequest;

$getResponse->send(new GetContactByIdRequest(contactId: 'pVyRW'));

Rate limiting

The connector ships with GetResponse's documented throttling limits (80 requests/second and 30,000 requests per 10 minutes) via the Saloon rate limit plugin, backed by your default Laravel cache store.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

PHP Laravel GetResponse API Library

Topics

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Sponsor this project

 

Packages

 
 
 

Contributors

Languages