ephraimju / stannp-php
Stannp邮件API的PHP SDK
0.2.3
2022-05-12 19:25 UTC
Requires
- php: >=5.3.0
Requires (Dev)
- squizlabs/php_codesniffer: 3.x-dev
README
我们的API提供对Stannp批量邮件账户的程序访问。配置活动、提供数据以及触发邮件发送等操作都可以通过简单而安全的HTTP请求实现。此SDK旨在为将我们的API轻松集成到您的应用程序中提供一种方法。
有关参数和API选项的更多信息,可以在Stannp API文档中找到此处。
安装
最好通过composer安装
composer update ephraimju\stannpphp
必须引入自动加载器
require_once 'YOUR/PROJECT/ROOT/vendor/autoload.php';
API密钥必须在对象实例化时作为参数传递,或者在您的应用程序中设置为一个常量。没有有效的API密钥则无法工作。
示例
define("STANNP_API_KEY", "API_KEY_HERE"); or $user = new User("API_KEY_HERE");
您可以在Stannp设置页面底部找到您的API密钥。
用法
与API一样,SDK被拆分为独立的组件。类和方法命名方案与API文档相匹配;这些类的完整列表如下
use Stannp\API\Campaigns; use Stannp\API\Groups; use Stannp\API\Letters; use Stannp\API\Postcard; use Stannp\API\Recipients; use Stannp\API\Reporting; use Stannp\API\User;
用法示例
use Stannp\API\Postcard; $user = new User(); $user->getMe();
use Stannp\API\Postcard $postcard = new Postcard(); $postcard->create( "A6", "https://www.stannp.com/assets/samples/a6-postcard-front.jpg", "Hello World", "Signature goes here", "Mr", "John", "Smith", "123 Fakestreet", "Address ln 2", "Cityshire", "AB12 3CD", true, "GB" );
输出
所有输出均为JSON格式,要将其转换为PHP对象,请使用json_decode()