maegnes/zf2xmlapisendeffect

将 sendeffect xml api 集成到您的 zf2 应用程序的 ZF2 模块

v1.1.0 2015-01-22 15:51 UTC

This package is not auto-updated.

Last update: 2024-09-28 16:10:15 UTC


README

Build Status

ZF2XmlApiSendeffect

将 sendeffect xml api 集成到您的应用程序的 ZF2 模块

通过 Composer 安装

只需将以下依赖项添加到您的 composer.json 文件中,并将模块 "ZF2XmlApiSendeffect" 添加到您的 application.config.php 中的应用程序模块列表中。

{
    "require": {
		"maegnes/zf2xmlapisendeffect": ">=1.0.0"
    }
}

然后,将以下结构添加到您的应用程序配置中

<?php
return array(
    'ZF2XmlApiSendeffect' => array(
        'apiUrl' => 'The https Endpoint of the API',
        'username'  => 'Your API Username',
        'usertoken' => 'Your API Usertoken'
    )
);

可用服务

AddSubscriberToList

将订阅者添加到指定的 sendeffect 订阅者列表中。

用法

<?php

// Inside your zf2 application, just fetch the service by the service manager

/** \ZF2XmlApiSendeffect\Service\AddSubscriberToList $emailService */
$emailService = $this->getServiceManager()->get('sendeffect_add_subscriber_to_list');

// Set the email address of the subscriber and the target list id
$emailService->setEmailAddress('John.Doe@yahoo.com');
$emailService->setMailingList(233);

// Then, add optional defined fields
$name = array(
    'fieldid' => 12,
    'value' => 'John'
);

$surname = array(
    'fieldid' => 13,
    'value' => 'Doe'
);

$emailService->addCustomFields([$name, $surname]);


# Finally call the api

/** \ZF2XmlApiSendeffect\Api\Response\ResponseInterface $response */
$response = $emailService->send();

if ($response->isSuccess()) {
    # Your logic
}

DeleteSubscriber

从给定的列表中删除订阅者

用法

<?php

// Inside your zf2 application, just fetch the service by the service manager

/** \ZF2XmlApiSendeffect\Service\DeleteSubscriber $emailService */
$emailService = $this->getServiceManager()->get('sendeffect_delete_subscriber');

// Set the email address of the subscriber and the target list id
$emailService->setEmailAddress('John.Doe@yahoo.com');
$emailService->setMailingList(233);

# Finally call the api

/** \ZF2XmlApiSendeffect\Api\Response\ResponseInterface $response */
$response = $emailService->send();

if ($response->isSuccess()) {
    # Your logic
}

GetSubscribers

返回给定订阅者列表中的所有订阅者

用法

<?php

// Inside your zf2 application, just fetch the service by the service manager

/** \ZF2XmlApiSendeffect\Service\GetSubscribers $emailService */
$emailService = $this->getServiceManager()->get('sendeffect_get_subscribers');

// For instance its possible to search for all @yahoo.com mail addresses
$emailService->setEmailAddress('@yahoo.com');
$emailService->setMailingList(233);

# Finally call the api

/** \ZF2XmlApiSendeffect\Api\Response\GetSubscribersResponse $response */
$response = $emailService->send();

if ($response->isSuccess()) {

    # Your logic

    // Get the subscribers count
    $count = $response->getCount();

    // Get the subscribers
    $subscribers = $response->getSubscribers();
}

IsSubscriberOnList

检查给定的用户是否在指定的订阅者列表中

用法

<?php

// Inside your zf2 application, just fetch the service by the service manager

/** \ZF2XmlApiSendeffect\Service\IsSubscriberOnList $emailService */
$emailService = $this->getServiceManager()->get('sendeffect_is_subscriber_on_list');

// Check if the user John.Doe@yahoo.com is on the mailing list 233
$emailService->setEmailAddress('John.Doe@yahoo.com');
$emailService->setMailingList(233);

# Finally call the api

/** \ZF2XmlApiSendeffect\Api\Response\IsSubscriberOnListResponse $response */
$response = $emailService->send();

if ($response->isSuccess()) {

    # Your logic

    $userExists = $response->userExists(); # true/false

}