Git Product home page Git Product logo

rapidmail-apiv3-client-php's Introduction

rapidmail Logo rapidmail APIv3 client

API client written in PHP providing access to the current version of the rapidmail API.

CI Status Latest Stable Version

Installation With Composer

Preferred installation method is to use the Composer dependency manager.

composer require rapidmail/rapidmail-apiv3-client-php

Getting started

Create a new API client instance and provide your APIv3 credentials:

require_once __DIR__ . '/vendor/autoload.php';

use Rapidmail\ApiClient\Client;

$client = new Client('api_username_hash', 'api_password_hash');

After that you can access various services encapsulated within the client:

$mailingService = $client->mailings();

// Iterate all mailings 

foreach($mailingService->query() as $mailing) {
    var_dump($mailing);
}

Examples

Retrieve mailings

Get a list of your mailings with some filters applied:

// Filter for sent mailings newer than a given date 

var_dump(
    $mailingService->query([
        'created_since' => '2019-09-01 10:22:00',
        'status' => 'sent'
    ])
);

Retrieve recipient lists

$listService = $client->recipientlists();

foreach ($listService->query() as $list) {
    var_dump($list);
}

Retrieve recipients

$recipientsService = $client->recipients();

$collection = $recipientsService->query(
    [
        'recipientlist_id' => 123456789 // Recipientlist ID MUST be provided
    ]
);

foreach ($collection as $recipient) {
    var_dump($recipient);
}

Create a new recipient

$recipientsService = $client->recipients();

var_dump(
    $recipientsService->create(
        // Dataset: Represents the recipient dataset you're creating
        [
            'recipientlist_id' => 123456789, // Required
            'email' => '[email protected]', // Required
            'firstname' => 'John',
            'lastname' => 'Doe',
            'gender' => 'male'
        ],
        // Flags: Configures system behavior, like sending activationmails
        [
            'send_activationmail' => 'yes'
        ]
    )
);

Error handling

Always keep in mind to handle errors properly and catch exceptions that might occur:

use \Rapidmail\ApiClient\Exception\ApiClientException;

try {
    $mailingService->query(['status' => 'unknown']);
} catch (ApiClientException $e) {
    // Catch API client exceptions
    echo "Exception raised: " . $e->getMessage();
}

Documentation

More information about using the API client can be found in the following subsections:

Known issues

  • Exceptions on 201 HTTP-Response-Code (used when a dataset was successfully created) are generated when using PHP Versions 7.4.5 and 8.1.2. If you're having issues with these versions, please try updating to a later version of PHP.

Also refer to the API documentation for a complete list of the available endpoints and their parameters.

License

rapidmail APIv3 client is licensed under the terms of the BSD 2-clause license.

Support

Contact: www.rapidmail.de - [email protected] - +49 761 - 216 08 720

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.