rewake / sendlane
Sendlane API SDK for PHP
v1.0.1
2019-06-17 18:55 UTC
Requires (Dev)
- phpunit/phpunit: ^4.8
This package is auto-updated.
Last update: 2024-09-08 06:32:49 UTC
README
这是一个针对Sendlane API(www.sendlane.com)的快速SDK。方法名称与API端点匹配,以帮助保持一致性,并可能使其更容易与Sendlane集成。
一些注意事项
- 此库抛出异常,应由您的应用程序处理
- 您可以将此库作为实例化对象或静态使用
- 有关Sendlane API的工作方式更多信息,请参阅Sendlane的API文档:https://documenter.getpostman.com/view/7477734/S1TN5g5b?version=latest
- 我有一些实例化测试,但可能没有时间很快写出更多
示例
实例化
基本实例化
try {
// Create Sendlane object
$sendlane = new Sendlane('subdomain', 'key', 'hash');
} catch (\Exception $e) {
// Echo error message
echo $e->getMessage();
}
实例化后的配置
允许在不销毁和重新创建Sendlane类的情况下切换账户(未测试)。configure()
方法也是可链式的。
try {
// Create Sendlane object
$sendlane = new Sendlane();
// Configure
$sendlane->configure('subdomain', 'key', 'hash');
} catch (\Exception $e) {
// Echo error message
echo $e->getMessage();
}
向列表添加订阅者
面向对象的调用
try {
// Create Sendlane object
$sendlane = new Sendlane('subdomain', 'key', 'hash');
// Add subscriber to a list
$result = $sendlane->list_subscriber_add([
'email' => 'test@test.com',
'list_id' => 1
]);
} catch (\Exception $e) {
// Echo error message
echo $e->getMessage();
}
静态调用
try {
// Make static API call
SendlaneClient::api(
'subdomain',
'list-subscriber-add',
[
'key' => 'your-api-key',
'hash' => 'your-api-hash',
'email' => 'user@domain.com',
'list_id' => 1
]
);
} catch (\Exception $e) {
// Echo error message
echo $e->getMessage();
}
获取用户详情
请注意,此方法需要必要的参数。对于所有属性都必需的端点,属性作为方法参数强制执行,以帮助防止数据丢失。请参阅API文档,了解哪些属性可以发送到哪个端点。
try {
// Create Sendlane object
$sendlane = new Sendlane('subdomain', 'key', 'hash');
// Add subscriber to a list
$result = $sendlane->user_details('test@test.com', 'password');
} catch (\Exception $e) {
// Echo error message
echo $e->getMessage();
}
一般API信息
示例API调用(所有调用均为POST方法)
https://SUBDOMAIN.sendlane.com/api/v1/METHOD?api=APIKEY&hash=HASHKEY
API调用列表(所有调用均为POST方法)
/api/v1/user-details
/api/v1/list-subscribers-add
/api/v1/list-subscriber-add
/api/v1/subscribers-delete
/api/v1/unsubscribe
/api/v1/list-create
/api/v1/list-update
/api/v1/list-delete
/api/v1/lists
/api/v1/opt-in-form
/api/v1/opt-in-create
/api/v1/subscriber-export
/api/v1/tags
/api/v1/tag-create
/api/v1/tag-subscriber-add
/api/v1/tag-subscriber-remove
/api/v1/subscriber-exists