chencha/everlytic

此包的最新版本(dev-master)没有提供许可证信息。

为Everlytic批量邮件API提供了一个简单优雅的包装,以实现laravel框架内的使用

dev-master 2014-05-21 18:21 UTC

This package is not auto-updated.

Last update: 2024-09-14 15:27:15 UTC


README

#Everlytic API Wrapper

这提供了对everlytic批量邮件API的Laravel包装。

API中没有添加额外的函数。

API的文档可以在以下地址找到 http://www.everlytic.co.za/features/integration/api-php-library/

##安装

  1. 更新你的composer.json文件并修改此行为require ***

    "chencha/everlytic": "dev-master"

  2. 运行composer update以获取文件

  3. 在你的app/config/app.php中注册服务提供者

    'providers' => array(

     'Chencha\Everlytic\EverlyticServiceProvider',
    

    )

  4. 在app/config/app.php中注册外观

    'aliases' => array(

     'Everlytic'=>'Chencha\Everlytic\Facades\Everlytic',
    

    )

  5. 使用Artisan CLI发布你的凭证

    php artisan config:publish chencha/everlytic ***

编辑配置文件

app/config/packages/chencha/everlytic/api.php

将用户、URL和API密钥替换为everlytic提供的值

##使用方法

包装器提供了对php API库提供的所有底层函数的访问。

示例用法

<?php
Create a new contact
$contact = array();
$contact['contact_mobile'] = '0726785544';
$contact['contact_email'] = 'bob@test.com';
$contact['contact_name'] = 'bob';
$contact['contact_lastname'] = 'jones';
$listIds = array(
    1 => CONTACT_SUBSCRIPTION_STATUS_SUBSCRIBED,
    2 => CONTACT_SUBSCRIPTION_STATUS_SUBSCRIBED
);
$contact['list_id'] = $listIds;
$contact['on_duplicate'] = CONTACT_ACTION_UPDATE;
$result = Everlytic::createContact($contact);
// Contact - get
$createdContactId = $result['result']['id'];

$gotContact = Everlytic::getContact($createdContactId);

// Contact - getBatch
$filter = array();
$filter['contact_country_id'] = '1';

$page = 1;
$count = 10;
$order = 'contact_name';
$direction = ORDER_ASC;
$result = Everlytic::listContacts($filter, $page, $count, $order, $direction);

// Contact - update
$updates = array();
$updates['contact_name'] = 'test';
$result = Everlytic::updateContact(1, $updates);

// List - getBatch
$filter = array();
$filter['list_name'] = 'none';

$page = 1;
$count = 10;
$order = 'list_name';
$direction = ORDER_ASC;
$result = Everlytic::getLists($filter, $page, $count, $order, $direction);

// List - create
$list = array();
$list['list_name'] = 'testing_list';
$list['list_owner_name'] = 'john';
$list['list_owner_email'] = 'jh@example.com';
$result = Everlytic::createList($list);
$createdListId = $result['id'];

// List - get
$gotList = Everlytic::getList($createdListId);

// Message - getBatch
$filter = array();
$filter['message_type'] = MESSAGE_TYPE_EMAIL;

$page = 1;
$count = 10;
$order = 'message_subject';
$direction = ORDER_ASC;
$result = Everlytic::getMessages($filter, $page, $count, $order, $direction);

// Message - create
$message = array();
$message['message_subject'] = 'a test message';
$message['message_from_email'] = 'message@test.com';
$message['message_from_name'] = 'johnny tester';
$message['message_reply_email'] = 'jt@test.com';
$message['message_type'] = MESSAGE_TYPE_EMAIL;
$result = Everlytic::createMessage($message);
$createdMessageId = $result['id'];

// Message - get
$gotMessage = Everlytic::getMessage($createdMessageId);

// Message - update
$updates = array();
$updates['message_from_name'] = 'Michael';
$result = Everlytic::updateMessage($createdMessageId, $updates);

?>