scn/evalanche-reporting-api-connector

Evalanche Reporting API官方PHP客户端

v2.0.0 2022-05-31 08:36 UTC

This package is auto-updated.

Last update: 2024-08-30 01:20:09 UTC


README

Monthly Downloads License Build Status

安装

通过Composer

$ composer require scn/evalanche-reporting-api-connector

用法

通用

首先使用SC-Networks提供的访问凭证创建一个连接。

use Scn\EvalancheReportingApiConnector\Enum\Language;
use Scn\EvalancheReportingApiConnector\Enum\TimeFormat;
use Scn\EvalancheReportingApiConnector\EvalancheConfig;
use Scn\EvalancheReportingApiConnector\EvalancheConnection;

$connection = EvalancheConnection::create(
    new EvalancheConfig(
        'your evalanche hostname (no uri, just the hostname)',
        'username',
        'password',
        Language::LANG_EN,
        TimeFormat::ISO8601,
    ),
    // $requestFactory, (optional existing PSR-17 RequestFactory instance)
    // $httpClient, (optional existing PSR-18 Http-Client instance)
);

EvalancheConnection类为每个表提供一种方法。例如,方法getPools()查询'pools'表。

这些方法每个都返回一个特定的客户端类,例如PoolsClient,以指定更多选项并接收不同格式的数据。

一个简单的示例可以是:

$connection->getPools()->asXml();

可用的方法遵循"流畅接口"模式,这意味着它们支持方法链。

格式化方法的调用,如asXml()或asCsv(),总是链中的最后一个调用,因为它返回数据。

方法

以下方法可用

  • getArticleReferences(int $customer_id)
  • getCustomers()
  • getForms()
  • getGeoCoordinates(int $customer_id)
  • getLeadpages(int $customerId = null)
  • getMailings()
  • getMilestoneProfiles(int $customer_id)
  • getNewsletterSendlogs(int $customer_id)
  • getPools()
  • getProfileChangelogs(int $pool_id)
  • getProfiles(int $pool_id)
  • getProfileScores()
  • getResourceTypes()
  • getScoringCluster()
  • getScoringGroups()
  • getScoringHistory()
  • getTrackingHistory()
  • getTrackingTypes()

格式

当前状态下,您可以选择以下格式

JsonArray

示例

$connection->getPools()->asJsonArray();

返回stdClass对象的数组。

JsonObject

示例

$connection->getPools()->asJsonObject();

返回stdClass对象。

XML

示例

$connection->getPools()->asXml();

返回包含有效XML的字符串。

CSV

示例

$connection->getPools()->asCsv();

返回包含逗号分隔值的字符串。第一行包含列标题。

参数

一些表提供更多选项或必选参数

客户ID (int)

使用它以获取特定客户的查询结果,而不是当前客户的。

示例
$connection->getLeadpages(1234)->asJsonArray();
  • getLeadpages (可选)
  • getNewsletterSendlogs
池ID (int)

您想要获取结果的池的ID。

示例
$connection->getProfiles(123)->asJsonArray();
  • getProfiles
  • getLeadpages

时间限制

使用方法withTimeRestriction(string $from = null, string $to = null)限制结果到定义的时间跨度。两个参数都是可选的,可以用null替换。

示例

从昨天开始的所有内容

$connection
    ->getMailings()
    ->withTimeRestriction('yesterday')
    ->asJsonArray();

从日期到昨天

$connection
    ->getMailings()
    ->withTimeRestriction('2018-09-27', 'yesterday')
    ->asJsonArray();

直到昨天的一切

$connection
    ->getMailings()
    ->withTimeRestriction(null, 'yesterday')
    ->asJsonArray();
可能值
  • 日期: 2018-08-0303.08.2018
  • 日期和时间: 03.08.2018 07:30
  • 相对值: yesterdaylast mondaynow-24hours等。
  • getMailings
  • getNewsletterSendLogs
  • getProfiles
  • getScoringHistory
  • getTrackingHistory

语言

默认语言为英语,但在建立连接时可以传递不同的语言代码。

使用类\Scn\EvalancheReportingApiConnector\Enum\Language中提供的枚举。

示例
use Scn\EvalancheReportingApiConnector\Enum\Language;
use Scn\EvalancheReportingApiConnector\EvalancheConnection;

$connection = EvalancheConnection::create(
    'given host',
    'given username',
    'given password',
    Language::LANG_DE
);
可能值
  • 英语: Language::LANG_EN
  • 德语: Language::LANG_DE
  • 意大利语: Language::LANG_IT
  • 法语: Language::LANG_FR

时间格式

默认时间格式为iso8601,但在建立连接时可以传递不同的格式代码。

使用类\Scn\EvalancheReportingApiConnector\Enum\TimeFormat中提供的枚举。

示例
use Scn\EvalancheReportingApiConnector\EvalancheConnection;
use Scn\EvalancheReportingApiConnector\Enum\Language;
use Scn\EvalancheReportingApiConnector\Enum\TimeFormat;

$connection = EvalancheConnection::create(
    'given host',
    'given username',
    'given password',
    Language::LANG_DE,
    TimeFormat::UNIX,
);
可能值
  • TimeFormat::ISO8601
  • TimeFormat::UNIX
  • TimeFormat::RFC822
  • TimeFormat::RFC850
  • TimeFormat::RFC1036
  • TimeFormat::RFC1123
  • TimeFormat::RFC2822
  • TimeFormat::RFC3339
  • TimeFormat::W3C

许可证

麻省理工学院许可证(MIT)。请参阅许可文件获取更多信息。