larsnieuwenhuizen/trustpilot

与 Trustpilot API 通信的 PHP 库

1.0.1 2020-06-05 19:47 UTC

This package is auto-updated.

Last update: 2024-09-21 15:13:13 UTC


README

Code Climate Test Coverage Build Status StyleCI

Trustpilot

与 Trustpilot 通信的 PHP 库

开发中

此包目前正在开发中(2017-04-12)

此包最初将仅支持需要通过 API 密钥访问的公共路由。稍后,将添加带有 OAuth 支持的私有请求。

功能调用

  • 业务单元

    • 获取公共业务单元
    • 获取业务单元的评论
    • 获取业务单元的分类
    • 获取业务单元的网页链接
    • 获取业务单元列表
  • 分类

    • 获取分类
    • 列出分类中的业务单元
  • 消费者

    • 获取消费者的评论
    • 获取消费者的个人资料
    • 获取消费者个人资料(包含 #评论 和网页链接)

示例配置

配置类会在项目根目录中搜索 config.yaml 文件,并默认使用这些设置。

您也可以使用 Configuration 构造函数定义不同的文件,如下所示

$configuration = new Trustpilot\Configuration('path/to/my/config.yaml');

如果拥有该文件,配置可以设置如下

TrustPilot:
  baseUrl: 'https://api.trustpilot.com/'
  basePath: 'v1/'
  resultsPerPage: 5
  orderBy: 'createdat.desc'
  apiKey: 'myApiKey'

如果没有 yaml 文件,可以使用设置器创建 Configuration。设置器始终可以用来覆盖任何 Configuration 属性。

$configuration = new \LarsNieuwenhuizen\Trustpilot\Configuration();
$configuration->setBaseUrl('https://api.trustpilot.com/')
    ->setBasePath('v1/')
    ->setDefaultResultsPerPage(5)
    ->setDefaultOrderBy('createdat.desc')
    ->setApiKey('apikey');

$client = new \LarsNieuwenhuizen\Trustpilot\Client($configuration);

$result = $client->businessDataService->getAllBusinessUnits();

通过 composer 安装

$ composer require larsnieuwenhuizen/trustpilot