romanpitak/dotmailer-api-v2-client
Composer 安装命令:
composer require romanpitak/dotmailer-api-v2-client
包简介
Client library for the dotMailer v2 (REST) API.
关键字:
README 文档
README
(c) 2014-2016 Roman Piták, http://pitak.net roman@pitak.net
PHP client library for the dotMailer v2 (REST) API with multiple accounts support!
Full implementation according to the http://api.dotmailer.com/v2/help/wadl
Type hinting support for objects and resources (not yet for arrays).
Installation
The best way to install is to use the Composer dependency manager.
php composer.phar require romanpitak/dotmailer-api-v2-client
Usage
Single account usage
<?php require_once('vendor/autoload.php'); $credentials = array( Container::USERNAME => 'apiuser-XXXXXXXXXXXX@apiconnector.com', Container::PASSWORD => 'YYYYYYYYYYYYYYYYYYYYYYYYYYY' ); $resources = Container::newResources($credentials); echo $resources->GetAccountInfo();
Multiple accounts usage
<?php require_once('vendor/autoload.php'); $credentials = array( 'master' => array( Container::USERNAME => 'apiuser-XXXXXXXXXXXX@apiconnector.com', Container::PASSWORD => 'YYYYYYYYYYYYYYYYYYYYYYYYYYY' ), 'group1' => array( 'g1-account1' => array( Container::USERNAME => 'apiuser-XXXXXXXXXXXX@apiconnector.com', Container::PASSWORD => 'YYYYYYYYYYYYYYYYYYYYYYYYYYY' ), 'g1-account2' => array( Container::USERNAME => 'apiuser-XXXXXXXXXXXX@apiconnector.com', Container::PASSWORD => 'YYYYYYYYYYYYYYYYYYYYYYYYYYY' ) ) ); $container = Container::newContainer($credentials); echo $container->getResources('master')->GetSegments(); $dataField = new ApiDataField(); $dataField->name = 'MY_DATA_FIELD'; $dataField->type = ApiDataTypes::STRING; $dataField->visibility = ApiDataFieldVisibility::HIDDEN; foreach ($container->group1 as $resources) { try { $resources->PostDataFields($dataField); echo 'OK'; } catch (Exception $e) { echo 'Already exists'; } }
Create campaign with images (real life example)
<?php // find the correct custom from address $customFromAddresses = $account->GetCustomFromAddresses(); $customFromAddress = null; foreach ($customFromAddresses as $cfa) { if ('roman@pitak.net' == $cfa->email) { $customFromAddress = $cfa; break; } } if (is_null($customFromAddress)) { throw new \Exception('Custom from address not found in the account.'); } // Create campaign to get campaign ID // we need the campaign id later to create image folder $campaign = new ApiCampaign(); $campaign->name = 'My API Campaign'; $campaign->subject = 'Api Works'; $campaign->fromName = "Roman Piták"; $campaign->fromAddress = $customFromAddress->toJson(); // empty content (must include unsubscribe links) $campaign->htmlContent = '<a href="http://$unsub$">UNSUB</a>'; $campaign->plainTextContent = 'http://$unsub$'; // save campaign $campaign = $account->PostCampaigns($campaign); // Create image folder $folder = new ApiImageFolder(); $folder->name = date('c') . ' cid=' . (string)$campaign->id; $folder = $account->PostImageFolder(new XsInt(0), $folder); $folderId = $folder->id; // Upload images foreach ($images as $baseName => $data) { $apiFileMedia = new ApiFileMedia(); $apiFileMedia->fileName = pathinfo($data['file'], PATHINFO_FILENAME); $apiFileMedia->data = base64_encode(file_get_contents($data['file'])); $apiImage = $account->PostImageFolderImages($folderId, $apiFileMedia); // set the dotMailer src for the images $images[$baseName]['src'] = (string)$apiImage->path; } // UPDATE CAMPAIGN $campaign->id = $campaign->id->toJson(); // getIndexHtml returns the html of the email with the correct src attribute for the images // it uses the $images array $htmlContent = getIndexHtml($includeDirectory); $campaign->htmlContent = $htmlContent; $html2text = new Html2Text($htmlContent); $campaign->plainTextContent = $html2text->get_text(); $account->UpdateCampaign($campaign);
romanpitak/dotmailer-api-v2-client 适用场景与选型建议
romanpitak/dotmailer-api-v2-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 101.07k 次下载、GitHub Stars 达 21, 最近一次更新时间为 2014 年 03 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「rest」 「api」 「client」 「v2」 「dotmailer」 「version 2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 romanpitak/dotmailer-api-v2-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 romanpitak/dotmailer-api-v2-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 romanpitak/dotmailer-api-v2-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Api bundle
Mock PSR-18 HTTP client
Asynchronous MQTT client built on React
Client for Google Directions API to add interpolated points to a route consisting of given coordinates.
A Flickr wrapper to allow you to call the Flickr api with Guzzle as the backend.Goal is to have 100% Flickr api coverage rather than just upload/display photos (currently at 23%).
统计信息
- 总下载量: 101.07k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 21
- 点击次数: 8
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-03-02