PHP code example of thedigit / laravel5.7-newsletter
1. Go to this page and download the library: Download thedigit/laravel5.7-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/ */
thedigit / laravel5.7-newsletter example snippets
// at the top of your class
use Newsletter;
// ...
Newsletter::subscribe('[email protected]');
Newsletter::unsubscribe('[email protected]');
//Merge variables can be passed as the second argument
Newsletter::subscribe('[email protected]', ['firstName'=>'Sam', 'lastName'=>'Vines']);
//Subscribe someone to a specific list by using the third argument:
Newsletter::subscribe('[email protected]', ['firstName'=>'Nanny', 'lastName'=>'Ogg'], 'Name of your list');
//Subscribe someone to a specific list and ember activity, returns an array with recent activity for a given user
Newsletter::getMemberActivity('[email protected]');
//Get the members for a given list, optionally filtered by passing a second array of parameters
Newsletter::getMembers();
//Check if a member is subscribed to a list
Newsletter::isSubscribed('[email protected]');
//Returns a boolean
Newsletter::hasMember('[email protected]');
//If you want to do something else, you can get an instance of the underlying API:
Newsletter::getApi();
return [
/*
* The API key of a MailChimp account. You can find yours at
* https://us10.admin.mailchimp.com/account/api-key-popup/.
*/
'apiKey' => env('MAILCHIMP_APIKEY'),
/*
* 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' => [
/*
* A MailChimp list id. Check the MailChimp docs if you don't know
* how to get this value:
* http://kb.mailchimp.com/lists/managing-subscribers/find-your-list-id.
*/
'id' => env('MAILCHIMP_LIST_ID'),
],
],
/*
* If you're having trouble with https connections, set this to false.
*/
'ssl' => true,
];