dmt-software/laposta-api 问题修复 & 功能扩展

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

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

dmt-software/laposta-api

最新稳定版本:0.4.0

Composer 安装命令:

composer require dmt-software/laposta-api

包简介

Client to consume the Laposta API

README 文档

README

An Object-Oriented client to consume the Laposta API.

Install

composer require dmt-software/laposta-api

Configure

After installing this package you need to configure it. The quickest way to do this is simply add a config file and use it to load the config into a Config instance.

// file: config.php return [ 'apiKey' => 'JdMtbsMq2jqJdQZD9AHC', 'customFieldsClasses' => [], 'httpClient' => \GuzzleHttp\Client::class, 'requestFactory' => \GuzzleHttp\Psr7\HttpFactory::class, ];

Generate entity

The next step is to generate an entity for the custom fields for the mailing list(s).

vendor/bin/laposta generate:list-fields config.php -l BaImMu3JZA

More in depth information about the custom fields can be found in the subscribers documentation.

Usage

Initiate a Client

The easiest way to create a client instance is using the factories in this package. These factories can also be used (as guideline) in a dependency injection container.

use DMT\Laposta\Api\Clients\Subscribers; use DMT\Laposta\Api\Config; use DMT\Laposta\Api\Factories\CommandBusFactory; $commandBus = CommandBusFactory::create(Config::load('config.php')); $client = new Subscribers($commandBus);

Subscribe a user to a mailing list

use DMT\CommandBus\Validator\ValidationException; use DMT\Laposta\Api\Entity\BaseCustomFields; use DMT\Laposta\Api\Entity\Subscriber; use DMT\Laposta\Api\Clients\Subscribers; use Psr\Http\Client\ClientExceptionInterface; try { /** @var BaseCustomFields $customFields The generated entity for your list */ $subscriber = new Subscriber(); $subscriber->listId = 'BaImMu3JZA'; $subscriber->email = 'user@example.com'; $subscriber->customFields = $customFields; $subscriber->customFields->name = 'John Do'; /** @var Subscribers $client */ $client->create($subscriber, Subscribers::OPTION_SUPPRESS_EMAIL_NOTIFICATION); } catch (ValidationException $exception) { // input was wrong  } catch (ClientExceptionInterface $exception) { // error response }

More on how to use this package can be found in the client documentation.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固