csb/php

适用于PHP应用的CSB软件包。

2.0.3 2021-01-04 11:04 UTC

This package is auto-updated.

Last update: 2024-09-04 20:04:03 UTC


README

需求

php >= 5.4

安装软件包

composer require csb/php -vvv --no-scripts --optimize-autoloader --ansi

更新软件包

composer update csb/php -vvv --no-scripts --optimize-autoloader --ansi

启动软件包

对于Laravel,将以下代码添加到AppServiceProvider.php的register函数中
$this->app->singleton('csb', function () {
    return new CSB(
        'https://{{domain}}.customersuccessbox.com',
        '{{secret}}',
        'async'
    );
});

$CSB = app('csb');
对于PHP,只需创建单例对象,在整个请求中有效
$CSB = new CSB(
    'https://{{domain}}.customersuccessbox.com',
    '{{secret}}',
    'async'
);
注意:我们只能在Linux系统上使用'async',对于Windows系统使用'sync'

函数

登录
$CSB->login('Account1', 'User1');
登出
$CSB->logout('Account1', 'User1');
账户 [account($accountID, $attributes = [])]
$CSB->account('Account1', ['attribute_1' => 'value1', 'attribute_2' => 'value2', 'custom_Field' => 'custom_value']);

账户属性

用户 [user($accountID, $userID, $attributes = [])]
$CSB->user('Account1', 'User1', ['attribute_1' => 'value1', 'attribute_2' => 'value2', 'custom_Field' => 'custom_value']);

用户属性

订阅 [subscription($accountID, $subscriptionID, $attributes = [])]
$CSB->subscription('Account1', 'Subscription1', ['attribute_1' => 'value1', 'attribute_2' => 'value2']);

订阅属性

发票 [invoice($accountID = null, $subscriptionID = null, $invoiceID, $attributes = [])]
$CSB->invoice('Account1', null, 'Invoice1', ['attribute_1' => 'value1', 'attribute_2' => 'value2']);
$CSB->invoice(null, 'Subscription1', 'Invoice1', ['attribute_1' => 'value1', 'attribute_2' => 'value2']);

发票属性

功能 [feature($accountID, $userID, $productID, $moduleID, $featureID, $total = 1)]
向CSB发送功能
$CSB->feature('Account1', 'User1', 'ProductName', 'ModuleName', 'FeatureName');

功能属性