guilty/apsis 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

guilty/apsis

Composer 安装命令:

composer require guilty/apsis

包简介

APSIS PHP API Client

关键字:

README 文档

README

Latest Version on Packagist Total Downloads

APSIS API client, used for interacting with the APSIS API: http://se.apidoc.anpdm.com

Installation

You can install the package via composer:

composer require guilty/apsis

Laravel

This package is compatible with Laravel

You can publish the config file like so

php artisan vendor:publish --provider="Guilty\Apsis\ApsisServiceProvider" --tag="config"

This is the contents of the published config file:

return [
    /*
     * This is the API key for your APSIS account.
     * Read how to generate an api key here:
     * http://se.apidoc.anpdm.com/Help/GettingStarted/Getting%20started
     */
    "api_key" => env("APSIS_API_KEY")
];

To get started, add the following environment variable to your .env file:

APSIS_API_KEY="your-api-key"

You can use the facade like so:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class NewsletterController extends Controller
{
    public function index()
    {
        $newsletters = Apsis::newsletter()->getNewslettersPaginated(1, 10);
                   
        return view('home', [
            "newsletters" => $newsletters->Result->Items
        ]);
    }
}

API Usage

Available services

use \Guilty\Apsis\Factory;

$apiKey = "YOUR-API-KEY";

// Create a factory like so
$factory = Factory::create($apiKey);

// Then fetch the service you need
$accountService = $factory->account();
$eventService = $factory->event();
$subscriberService = $factory->subscriber();
$openService = $factory->open();
$bounceService = $factory->bounce();
$smsService = $factory->sms();
$filterService = $factory->filter();
$transactionalService = $factory->transactional();
$folderService = $factory->folder();
$clickService = $factory->click();
$mailingListService = $factory->mailingList();
$newsletterService = $factory->newsletter();
$sendingService = $factory->sending();
$optOutService = $factory->optOut();
$importService = $factory->import();

Account Service

$apiKey = "YOUR-API-KEY";
$accountService = Factory::create($apiKey)->account()
$accountService->createSingleSignOnUrl();
$accountService->getDemographicData();

Bounce Service

$apiKey = "YOUR-API-KEY";
$bounceService = Factory::create($apiKey)->bounce();
$bounceService->getAll();
$bounceService->getAllPaginated($pageNumber, $pageSize);
$bounceService->getBouncesForSendingPaginated($sendQueueId, $pageNumber, $pageSize);
$bounceService->getByDateInterval(\DateTimeInterface $start, \DateTimeInterface $end);
$bounceService->getByDateIntervalPaginated(\DateTimeInterface $start, \DateTimeInterface $end, $pageNumber, $pageSize);
$bounceService->getBySendqueueIds($sendqueueIds);

Click Service

$apiKey = "YOUR-API-KEY";
$clickService = Factory::create($apiKey)->click();
$clickService->getClicksBySendqueueIdPaginated($sendQueueId, $pageNumber, $pageSize);

Event Service

$apiKey = "YOUR-API-KEY";
$eventService = Factory::create($apiKey)->event();
$eventService->addAttendee($eventId, $sessionId, $attendeeData);
$eventService->getAttendees($eventId, $sessionId = null, $attendeeStatus = null);
$eventService->getControls($eventId);
$eventService->getEventParticipantStatus($eventId);
$eventService->getEvents();
$eventService->getEventSessionAttendee($eventId, $sessionId, $attendeeEmail);
$eventService->getEventsWithSessions($filters = null);
$eventService->getEventWithSessions($eventId);
$eventService->getOptionsDataCategories($eventId);
$eventService->registerAttendee($eventId, $sessionId, $attendeeData);
$eventService->updateAttendee($eventId, $sessionId, $attendeeId, $attendeeData);
$eventService->updateAttendeeStatus($eventId, $attendeeId, $attendeeStatus);

Filter Service

$apiKey = "YOUR-API-KEY";
$filterService = Factory::create($apiKey)->filter();
$filterService->createFilterByDemographicData($filterName, $demographicDataName, $operatorValue, $demographicDataValue);
$filterService->getAllFilters();

Folder Service

$apiKey = "YOUR-API-KEY";
$folderService = Factory::create($apiKey)->folder();
$filterService->createFilterByDemographicData($filterName, $demographicDataName, $operatorValue, $demographicDataValue);
$filterService->createFolder($folderName, $folderType);
$filterService->getAllFolders();

Mailing List Service

$apiKey = "YOUR-API-KEY";
$mailingListService = Factory::create($apiKey)->mailingList();
$mailingListService->createMailinglist($mailingListDetails);
$mailingListService->createSingleSubscription($mailinglistId, $subscriberId);
$mailingListService->createSubscriptions($mailinglistId, $recipientIds);
$mailingListService->deleteAllMailinglistSubscriptions($mailinglistId);
$mailingListService->deleteAllSubscriptionsForSubscriber($subscriberId);
$mailingListService->deleteMultipleMailingLists($mailinglistIds);
$mailingListService->deleteSingleSubscription($mailinglistId, $subscriberId);
$mailingListService->getAllMailingLists();
$mailingListService->getMailingListDetails($mailinglistId);
$mailingListService->getMailinglistsPaginated($pageNumber, $pageSize);
$mailingListService->getMailinglistSubscribers($mailinglistId, $allDemographics = false, $fieldNames = []);
$mailingListService->getMailinglistSubscribersPaginated($mailingListId, $pageNumber, $pageSize);
$mailingListService->getMailinglistSubscribersWithFilter($mailinglistId, $filterId, $allDemographics = false, $fieldNames = []);
$mailingListService->getMailinglistSubscriptionCount($mailinglistId);
$mailingListService->updateMailingList($mailinglistId, $mailingListDetails);

Newsletter List Service

$apiKey = "YOUR-API-KEY";
$newsletterListService = Factory::create($apiKey)->newsletter();
$newsletterListService->createNewsletter($newsletterData);
$newsletterListService->deleteMultipleNewsletters($newsletterIds);
$newsletterListService->deleteSingleNewsletter($newsletterId);
$newsletterListService->getAllNewsletters();
$newsletterListService->getNewsletterLinks($newsletterId);
$newsletterListService->getNewslettersPaginated($pageNumber, $pageSize);
$newsletterListService->getNewsletterWebVersionLink($newsletterId);
$newsletterListService->updateNewsletter($newsletterId, $newsletterData);

Open Service

$apiKey = "YOUR-API-KEY";
$openService = Factory::create($apiKey)->open();
$openService->getOpensBySendqueueIdPaginated($sendQueueId, $pageNumber, $pageSize);

Opt Out Service

$apiKey = "YOUR-API-KEY";
$optOutService = Factory::create($apiKey)->optOut();
$optOutService->deleteSubscriberFromOptOutAllByEmail($subscriberEmail);
$optOutService->deleteSubscribersFromOptOutAll($subscriberIds);
$optOutService->deleteSubscribersFromOptOutAllByEmail($subscriberEmails);
$optOutService->deleteSubscribersFromOptOutListByEmail($mailinglistId, $subscriberEmails);
$optOutService->getOptOutAll();
$optOutService->getOptOutAllByDateInterval(\DateTimeInterface $start, \DateTimeInterface $end);
$optOutService->getOptOutAllByDateIntervalPaginated(\DateTimeInterface $start, \DateTimeInterface $end, $pageNumber, $pageSize);
$optOutService->getOptOutAllPaginated($pageNumber, $pageSize);
$optOutService->getOptOutList($mailinglistId);
$optOutService->getOptOutListByMailingListPaginated($mailinglistId, $pageNumber, $pageSize);
$optOutService->getOptOutListBySendqueueId($sendQueueId);
$optOutService->getOptOutListBySendqueueIdPaginated($sendQueueId, $pageNumber, $pageSize);
$optOutService->moveSubscribersToOptOutList($mailinglistId, $optOutListSubscriberItems);
$optOutService->optOutAllSubscribers($optOutListSubscriberItems);

Sending Service

$apiKey = "YOUR-API-KEY";
$sendingService = Factory::create($apiKey)->sending();
$sendingService->deleteSendingById($sendQueueId);
$sendingService->getBounces($sendQueueId, \DateTimeInterface $dateFrom, \DateTimeInterface $dateTo);
$sendingService->getClicks($sendQueueId, \DateTimeInterface $dateFrom, \DateTimeInterface $dateTo);
$sendingService->getFutureSendings();
$sendingService->getOpens($sendQueueId, \DateTimeInterface $dateFrom, \DateTimeInterface $dateTo);
$sendingService->getOptOuts($sendQueueId, \DateTimeInterface $dateFrom, \DateTimeInterface $dateTo);
$sendingService->getPaginated($pageNumber, $pageSize);
$sendingService->getSendingById($sendQueueId);
$sendingService->getSendingsByDateInterval(\DateTimeInterface $start, \DateTimeInterface $end);
$sendingService->getSendingsByNewsletterId($newsletterId);
$sendingService->getSendingsBySubscriberId($subscriberId, $pageNumber, $pageSize);
$sendingService->sendNewsletter($newsletterDetails);

Sms Service

$apiKey = "YOUR-API-KEY";
$smsService = Factory::create($apiKey)->sms();
$smsService->createSmsMessage($name, $text, $folderId = null);
$smsService->getIncomingSmsMessages($numberRespondedTo, \DateTimeInterface $start, \DateTimeInterface $end);
$smsService->getSmsCredits();
$smsService->getSmsMessages();
$smsService->getSmsRecipientsBySendQueueId($sendQueueId);
$smsService->send($message, $countryCode, $phoneNumber, $senderName = null, $isLinked = false, \DateTimeInterface $sendDate = null);
$smsService->sendSmsMessage($smsMessageId, $mailingListIds, $senderName = null, \DateTimeInterface $sendDate = null, $filterId = null, $campaignId = null):

Subscriber Service

$apiKey = "YOUR-API-KEY";
$subscriberService = Factory::create($apiKey)->subscriber();
$subscriberService->createSubscriber($mailingListId, $updateIfExists, $subscriber);
$subscriberService->createSubscribers($mailinglistId, $subscribers);
$subscriberService->createSubscriberWithDoubleOptIn($mailinglistId, $subscriber);
$subscriberService->deleteMultipleSubscribersByEmail($subscriberEmails);
$subscriberService->deleteMultipleSubscribersById($subscriberIds);
$subscriberService->getAllSubscribers($allDemographics = true, $fieldNames = []);
$subscriberService->getAllSubscribersWithFilter($filterId, $allDemographics = true, $fieldNames = []);
$subscriberService->getAllSubscribersWithoutSubscription($allDemographics = true, $fieldNames = []);
$subscriberService->getRecipientsBySendQueueId($sendQueueId);
$subscriberService->getSubscriberDetailsById($subscriberId);
$subscriberService->getSubscriberIdByEmail($email);
$subscriberService->getSubscriberMailinglists($subscriberId);
$subscriberService->getSubscribersByExternalId($externalId);
$subscriberService->getSubscribersPaginated($pageNumber, $pageSize);
$subscriberService->updateSubscribers($subscribers);

Transactional Service

$apiKey = "YOUR-API-KEY";
$transactionalService = Factory::create($apiKey)->transactional();
$transactionalService->getTransactionalBounces($projectId, \DateTimeInterface $dateFrom = null, \DateTimeInterface $dateTo = null);
$transactionalService->getTransactionalClicks($projectId, \DateTimeInterface $dateFrom = null, \DateTimeInterface $dateTo = null);
$transactionalService->getTransactionalOpens($projectId, \DateTimeInterface $dateFrom = null, \DateTimeInterface $dateTo = null);
$transactionalService->getTransactionalProjects();
$transactionalService->getTransactionResult($transactionId, $includeDemographicData);
$transactionalService->sendTransactionalEmail($projectId, TransactionalEmail $transactionalEmail, \DateTimeInterface $sendDate = null, $allowInactiveProjects = true);

Import Service

$apiKey = "YOUR-API-KEY";
$importService = Factory::create($apiKey)->import();
$importService->createImportByCsv($mailingListId, CsvImport $csvImport);
$importService->createImportByXml($mailingListId, $xmlData, $demographicNameMapping = false);
$importService->getImportIgnoredDuplicates($importId);
$importService->getImportInvalidEmails($importId);
$importService->getImportRecipientsOnOptOutAll($importId);
$importService->getImportRecipientsOnOptOutList($importId);
$importService->getImportResults($importId);
$importService->getImportStatus($importId);

Queued Methods

To make it easier to work with Queued Methods, you can use the QueuedMethodHelper to poll and retrieve data from any queued method.

Just pass the response of a Queued Method into the QueuedMethodHelper::fromJson() method and you will have an instance.

Below is an example of how you could use this:

$factory = \Guilty\Apsis\Factory::create("YOUR-API-KEY");
$newsletterService = $factory->newsletter();

// 'deleteMultipleNewsletters' is a queued method.
$response = $newsletterService->deleteMultipleNewsletters([1, 2, 3, 4]);

// Pass the QueuedMethodHelper the response from a queued method.
$poll = QueuedMethodHelper::fromJson($response, $factory->getClient());

while (true) {
    echo "Polling: {$poll->getPollUrl()}";

    try {
        // Poll for latest status
        $poll->poll();

        // Check if the data is ready now.
        if ($poll->isDataReady()) {
            break; // Jump out of loop if it is.
        }

        // Wait 1 second
        sleep(1);
    } catch (Exception $e) {
        die("Something unexpected happened...");
    }
}

// Fetch the data
$queuedMethodDataResult = $poll->retrieveData();

Implemented Services

These services are currently implemented, the rest is being worked on and will be checked off once completed.

  • Account
  • Bounce
  • Click
  • Event
  • Filter
  • Folder
  • Import
  • MailingList
  • Newsletter
  • Open
  • OptOut
  • Sending
  • Sms
  • Subscriber
  • Transactional (NOTE: sendTransactionalEmail(), might not work right yet)

Security

If you discover any security related issues, please email tech@guilty.no instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.

Brought to you by Guilty AS

The APSIS logo and Trademark is the property of APSIS International AB

guilty/apsis 适用场景与选型建议

guilty/apsis 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 990 次下载、GitHub Stars 达 3, 最近一次更新时间为 2019 年 01 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「guilty」 「apsis」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 guilty/apsis 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 guilty/apsis 我们能提供哪些服务?
定制开发 / 二次开发

基于 guilty/apsis 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

与 guilty/apsis 相关的其它包

同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:

统计信息

  • 总下载量: 990
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-01-12