This bundle is used to integrate the SendyPHP class from Jacob Bennett into a symfony2 project.
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require jkabat/sendy-bundle
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Then, enable the bundle by adding the following line in the app/AppKernel.php
file of your project:
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
// ...
new Sendy\SendyBundle\SendyBundle(),
];
// ...
}
// ...
}
# app/config/config.yml
sendy:
api_key: sendy_api_key
api_host: https://sendy.installation.url
list_id: default_list_id
Get count of total active subscribers for default list:
// get service
$sendy = $this->container->get('sendy.sendy_manager');
$count = $sendy->getSubscriberCount();
Get count of total active subscribers for other list:
$sendy = $this->container->get('sendy.sendy_manager');
$count = $sendy->getSubscriberCount('other_list_id');
Get status of subscriber identified by e-mail:
$sendy = $this->container->get('sendy.sendy_manager');
$status = $sendy->getSubscriberStatus('[email protected]');
Subscribe user to default list (other list id can be used as third parameter):
$sendy = $this->container->get('sendy.sendy_manager');
$status = $sendy->subscribe('Name', '[email protected]');
Unsubscribe user from default list (other list id can be used as second parameter):
$sendy = $this->container->get('sendy.sendy_manager');
$status = $sendy->unsubscribe('[email protected]');