scaramangagency/trustpilot

此软件包已被废弃,不再维护。未建议替代软件包。

与Trustpilot API交互

1.0.0 2021-10-27 13:52 UTC

This package is auto-updated.

Last update: 2024-06-29 05:11:38 UTC


README

Trustpilot插件用于Craft CMS 3.x

要求

此插件需要Craft CMS 3.1.0或更高版本。

开始之前

Trustpilot插件需要已注册到标准计划并添加了Connect模块的Trustpilot企业账户。

安装Trustpilot插件

要安装插件,请按照以下说明操作。

  1. 打开您的终端并进入您的Craft项目目录

    cd /path/to/project
    
  2. 然后告诉Composer加载插件

    composer require scaramangagency/trustpilot
    
  3. 在控制面板中,转到设置→插件,并点击Trustpilot的“安装”按钮。

您还可以访问Craft插件商店,搜索Trustpilot并点击安装。

配置Trustpilot

分配用户权限

Trustpilot插件提供细粒度用户权限,您必须将其添加到现有和新用户组。

定义用户和/或用户组是否有以下权限

  • 管理设置
  • 查看评论
  • 管理评论上的评论
  • 发送邀请

插件设置

设置标签页下有下列选项可用

  • Trustpilot用户名 — 您的Trustpilot用户名。
  • Trustpilot密码 — 您的Trustpilot密码。
  • Trustpilot API密钥 — 您的Trustpilot API密钥。
  • Trustpilot API密钥 — 您的Trustpilot API密钥。

您可以通过访问Trustpilot的自己的文档来学习如何创建API密钥和API密钥。

  • Trustpilot网站URL — 与您的Trustpilot账户关联的网站URL。
  • 邀请发送者电子邮件 — 您希望Trustpilot邀请从该电子邮件发送。
  • 邀请发送者名称 — 您希望Trustpilot邀请从该名称发送。
  • 邀请回复至 — 响应者响应应发送到的电子邮件地址。

所有值都可以设置为环境变量。

在控制面板中使用Trustpilot

邀请

发送邀请

向客户发送邀请。输入他们的电子邮件和姓名(可选地,如果您想将他们发送到自定义感谢页面,则可以输入重定向URL)并点击“发送邀请”。这将在一小时内发送一封电子邮件。

您可以通过进入您的企业账户仪表板并访问获取评论>概览>查看完整的邀请历史来检查评论是否已发送。

生成评论链接

输入客户姓名和电子邮件,然后点击生成以获取邀请链接。然后您可以手动将链接发送给客户。

评论

显示您的Trustpilot账户中的所有评论。您可以通过点击“添加回复”来添加对评论的回复。如果您已经添加了回复,则可以点击“编辑回复”而不是“编辑回复”,这允许您编辑或删除现有的回复。

在模板中使用Trustpilot

您可以在模板中使用各种变量。请注意,每个变量返回一个不带任何样式的对象,因此开发者需要将这些对象添加适当的标记和样式。

关于缓存

此插件将在每次请求时向Trustpilot API发起请求。我们建议将API调用的输出缓存起来,可以使用Craft的本地缓存或静态页面缓存(如果您的网站已经进行了有效的优化,静态页面缓存应该已经包含在内)。

getAllReviews

返回所有评论。

craft.trustpilot.getAllReviews(page, limit, siteId)
字段名称 描述
page 分页时,插入您要获取的页面
limit 在分页(或仅限制结果集)时,选择从API获取的评论数量
siteId 当前网站的ID。如果您只有一个网站,可以留空,否则传递您已授权的网站的siteId。如果您仅在单个多站点安装上设置了授权,则可以硬编码网站ID,否则动态传递当前的siteId

响应

{ 
    "author" => [
        "name" => "Scaramanga Agency",
        "previousReviewCount" => 2
    ],
    "reviewStars" => [
        "count" => 3,
        "image" => "https://api.trustpilot.com/v1/resources/images/stars/3"
    ],
    "reviewTitle" => "Lorem Ipsum Dolor Sit Amet",
    "reviewText" => "Lorem Ipsum Dolor Sit Amet",
    "reviewPosted" => "2021-05-20T09:55:56Z",
    "companyReply" => "Lorem Ipsum Dolor Sit Amet"
}

getProfile

获取您的基本配置文件信息。

craft.trustpilot.getProfile(siteId)
字段名称 描述
siteId 当前网站的ID。如果您只有一个网站,可以留空,否则传递您已授权的网站的siteId。如果您仅在单个多站点安装上设置了授权,则可以硬编码网站ID,否则动态传递当前的siteId

响应

{ 
    "websiteUrl" => ""
    "displayName" => "Lorem Ipsum Dolor Sit Amet",
    "trustScore" => 3.6,
    "stars" => 3.5,
    "count" => [
        "total" => 2,
        "oneStar" => 0,
        "twoStars" => 0,
        "threeStars" => 1,
        "fourStars" => 1,
        "fiveStars" => 0
    ]
}

getTrustpilotStarImage

获取在提供的site ID上设置的Trustpilot账户的星级图像。

craft.trustpilot.getTrustpilotStarImage(siteId)
字段名称 描述
siteId 当前网站的ID。如果您只有一个网站,可以留空,否则传递您已授权的网站的siteId。如果您仅在单个多站点安装上设置了授权,则可以硬编码网站ID,否则动态传递当前的siteId

响应

{ 
    "star128x24" => [
        "width" => 128,
        "height" => 24,
        "url" => "//images-static.trustpilot.com/api/stars/3.5/128x24.png"
    ], 
    "star256x48" => [
        "width" => 256,
        "height" => 48,
        "url" => "//images-static.trustpilot.com/api/stars/3.5/256x48.png"
    ],
    "star512x96" => [
        "width" => 512,
        "height" => 96,
        "url" => "//images-static.trustpilot.com/api/stars/3.5/512x96.png"
    ],
    "starSvg" => [
        "width" => 128,
        "height" => 24,
        "url" => "//images-static.trustpilot.com/api/stars/3.5/star.svg"
    ],
    "stars" => 3.5
}

getTrustpilotStarText

获取在提供的site ID上设置的Trustpilot账户的星级评级的文本表示。

craft.trustpilot.getTrustpilotStarText(siteId)
字段名称 描述
siteId 当前网站的ID。如果您只有一个网站,可以留空,否则传递您已授权的网站的siteId。如果您仅在单个多站点安装上设置了授权,则可以硬编码网站ID,否则动态传递当前的siteId

响应

{
    "locale": "en-US",
    "string": "Good",
    "stars": 4
}

getTrustpilotPermalinks

获取在提供的site ID上设置的Trustpilot账户的永久链接(配置文件URL,嵌入URL)。

craft.trustpilot.getTrustpilotPermalinks(siteId)
字段名称 描述
siteId 当前网站的ID。如果您只有一个网站,可以留空,否则传递您已授权的网站的siteId。如果您仅在单个多站点安装上设置了授权,则可以硬编码网站ID,否则动态传递当前的siteId

响应

{
    "profileUrl"=> "https://www.trustpilot.com/review/XX", 
    "evaluateEmbedUrl" => "https://www.trustpilot.com/evaluate/embed/XX",
    "evaluateUrl"=> "https://www.trustpilot.com/evaluate/XX"
}

getTrustpilotIcons

获取Trustpilot图标资源。

craft.trustpilot.getTrustpilotIcons()

响应

{
    "icon230x230" => [
        "width" => 230,
        "height" => 230,
        "url" => "//images-static.trustpilot.com/api/icons/230x230.png"
    ]
}

getTrustpilotLogos

获取Trustpilot标志资源。

craft.trustpilot.getTrustpilotLogos()

响应

{
    "darkBackground": {
        "logo72x18": {
            "url": "//trustpilot.com/image.jpg",
            "width": "400",
            "height": "300"
        },
        "logo144x36": {
            "url": "//trustpilot.com/image.jpg",
            "width": "400",
            "height": "300"
        },
        "logo288x72": {
            "url": "//trustpilot.com/image.jpg",
            "width": "400",
            "height": "300"
        },
        "logo576x144": {
            "url": "//trustpilot.com/image.jpg",
            "width": "400",
            "height": "300"
        },
        "logoSvg": {
            "url": "//trustpilot.com/image.jpg",
            "width": "400",
            "height": "300"
        }
    },
    "lightBackground": {
        "logo72x18": {
            "url": "//trustpilot.com/image.jpg",
            "width": "400",
            "height": "300"
        },
        "logo144x36": {
            "url": "//trustpilot.com/image.jpg",
            "width": "400",
            "height": "300"
        },
        "logo288x72": {
            "url": "//trustpilot.com/image.jpg",
            "width": "400",
            "height": "300"
        },
        "logo576x144": {
            "url": "//trustpilot.com/image.jpg",
            "width": "400",
            "height": "300"
        },
        "logoSvg": {
            "url": "//trustpilot.com/image.jpg",
            "width": "400",
            "height": "300"
        }
    }
}

Scaramanga Agency提供