PHP code example of karacweb / infomaniak-newsletter

1. Go to this page and download the library: Download karacweb/infomaniak-newsletter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

karacweb / infomaniak-newsletter example snippets


return [
    /*
     * The API keys of an Infomaniak newsletter account. You can find yours at
     * https://newsletter.infomaniak.com/accounts/access-token
     */
    'apiKey' => env('INFOMANIAK_APIKEY'),
    'secretKey' => env('INFOMANIAK_SECRETKEY'),

    /*
     * The listName to use when no listName has been specified in a method.
     */
    'defaultListName' => 'subscribers',

    /*
     * Here you can define properties of the lists.
     */
    'lists' => [

        /*
         * This key is used to identify this list. It can be used
         * as the listName parameter provided in the various methods.
         *
         * You can set it to any string you want and you can add
         * as many lists as you want.
         */
        'subscribers' => [

            /*
             * Id of a newsletter contact list. You can retrieve it
             * by looking at the last characters of the list's URL :
             * https://newsletter.infomaniak.com/mailinglists/show/XXXXX
             */
            'id' => env('INFOMANIAK_LISTID'),

        ],
    ],
];

use InfomaniakNewsletter;

InfomaniakNewsletter::importContact("[email protected]");

InfomaniakNewsletter::importContact("[email protected]", ["firstname" => "John", "lastname" => "Doe"]);

InfomaniakNewsletter::importContact("[email protected]", [], "subscribers");

InfomaniakNewsletter::isSubscribed("[email protected]");

InfomaniakNewsletter::isSubscribed("[email protected]", "subscribers");

InfomaniakNewsletter::unsubscribeContact("[email protected]");

InfomaniakNewsletter::unsubscribeContact("[email protected]", "subscribers");

InfomaniakNewsletter::deleteContact("[email protected]");

InfomaniakNewsletter::deleteContact("[email protected]", "subscribers");

InfomaniakNewsletter::getContact("[email protected]");

InfomaniakNewsletter::getContacts();

InfomaniakNewsletter::getContacts("subscribers");

InfomaniakNewsletter::getContacts("subscribers", ["page" => 2, "perPage" => 50]);

InfomaniakNewsletter::updateContact("[email protected]", ["firstname" => "Joe"]);

InfomaniakNewsletter::updateContact("[email protected]", ["firstname" => "Joe", "lastname" => "Donovan"]);

InfomaniakNewsletter::getMailinglists();

InfomaniakNewsletter::getMailinglists(["page" => 1, "perPage" => 50]);

InfomaniakNewsletter::getMailinglist();

InfomaniakNewsletter::getMailinglist("subscribers");

InfomaniakNewsletter::createMailinglist("subscribers_fr");

InfomaniakNewsletter::updateMailinglist("subscribers_fr", "subscribers_french");

InfomaniakNewsletter::deleteMailinglist();

InfomaniakNewsletter::deleteMailinglist("subscribers_french");

InfomaniakNewsletter::getTask(123456);

php artisan vendor:publish --provider="Karacweb\InfomaniakNewsletter\ServiceProvider"