rivio/rivio-php-sdk

1.2.7 2019-02-20 13:18 UTC

README

Rivio PHP SDK 提供了对 Rivio API 的集成访问。

依赖关系

需要 PHP 版本 >= 5.2.0。

安装和配置

通过以下下载链接开始使用我们的 PHP SDK。

下载

或使用 Composer

Composer 是 PHP 的包管理器。在您的项目中的 composer.json 文件中添加以下内容:

{
  "require" : {
    "rivio/rivio-php-sdk": "*"
  }
}

然后运行

php composer.phar install

快速入门示例

为了测试,您需要您的 Rivio API 密钥 和您的 Secret 密钥。您可以从 此处 获取它们。

产品评论小部件

<?php

require_once 'PATH_TO_RIVIO_PHP_SDK/src/Rivio.php';

//Copy credentials from Rivio Dashboard (http://dashboard.getrivio.com/dashboard/settings/business)
$rivio = new Rivio('api_key','secret_key');

//Get the RIVIO script
$rivio_init_script=$rivio->get_init_js();

$rivio_embed_html=$rivio->product_reviews_widget(
    "1492411012", //$product_id REQUIRED
    "Samsung Galaxy S6", //$product_name REQUIRED
    "https://example.com/products/galaxy-s6", //$product_url OPTIONAL
    "https://images.example.com/big/200", //$product_image_url OPTIONAL
    "This is the product description", //$product_description OPTIONAL
    "1234567890123", //$product_barcode OPTIONAL
    "Mobile phone", //$product_category OPTIONAL
    "Samsung", //$product_brand OPTIONAL
    "499", //$product_price OPTIONAL
    $reviews_html //$reviews_html OPTIONAL (from product_reviews_html)
);

?>
<html>
    <head>
        <title>Embed module - Rivio PHP SDK example</title>
    </head>
    <body>
        <h1>Rivio Embed Module</h1>
        <?php echo $rivio_embed_html;?>
        <?php echo $rivio_init_script;?>
    </body>
</html>

注册购买后电子邮件

在您的商店完成购买后,此代码将向买家发送“购买后电子邮件”,以便他们可以撰写评论。
您还可以在此 配置此电子邮件发送。

<?php

require_once 'PATH_TO_RIVIO_PHP_SDK/src/Rivio.php';

//Copy credentials from Rivio Dashboard (http://dashboard.getrivio.com/dashboard/settings/business)
$rivio = new Rivio('api_key','secret_key');

$result = $rivio->register_post_purchase_email(
    "1492411013331", //$order_id REQUIRED
    "2015-09-28T09:16:16-04:00", //$ordered_date REQUIRED
    "user@example.com", //$customer_email REQUIRED
    "John", //$customer_first_name REQUIRED
    "1492411012", //$product_id REQUIRED
    "Samsung Galaxy S6", //$product_name REQUIRED
    "https://example.com/products/galaxy-s6", //$product_url OPTIONAL
    "https://images.example.com/big/200", //$product_image_url OPTIONAL
    "This is the product description", //$product_description OPTIONAL
    "1234567890123", //$product_barcode OPTIONAL
    "Mobile phone", //$product_category OPTIONAL
    "Samsung", //$product_brand OPTIONAL
    "499" //$product_price OPTIONAL
);

?>
<html>
    <head>
        <title>Register Postpurchase Email - Rivio PHP SDK example</title>
    </head>
    <body>
        <h1>Rivio Register Postpurchase Email</h1>
        <p>result:</p>
        <pre><?php print_r($result);?></pre>
        Check your postpurchase email queue on 
        <a href="http://dashboard.getrivio.com/dashboard/email/summary" target="_blank">Rivio Dashboard</a>.
        If the "Email status" is "Pending" then the test was successful.
    </body>
</html>

您可以使用以下示例添加多个产品。这样,Rivio 将选择订单中最昂贵的产品。如果产品没有价格信息,它将选择第一个产品。然后 Rivio 将发送关于该产品的 PostPurchase 电子邮件。

<?php

require_once 'PATH_TO_RIVIO_PHP_SDK/src/Rivio.php';

//Copy credentials from Rivio Dashboard (http://dashboard.getrivio.com/dashboard/settings/business)
$rivio = new Rivio('api_key','secret_key');

$products = array();

// The first product
array_push($products, array(
   "id" => "1492411013331", //$product_id REQUIRED
   "name" => "Samsung Galaxy S6", //$product_name REQUIRED
   "url" => "https://example.com/products/galaxy-s6", //$product_url OPTIONAL
   "image_url" => "https://images.example.com/big/200", //$product_image_url OPTIONAL
   "description" => "This is the product description", //$product_description OPTIONAL
   "barcode" => "1234567890123", //$product_barcode OPTIONAL
   "brand" => "Samsung", //$product_brand OPTIONAL,
   "price" => "499", //$product_price OPTIONAL
));

// The second product
array_push($products, array(
   "id" => "2811046815449", //$product_id REQUIRED
   "name" => "Google Pixel", //$product_name REQUIRED
   "url" => "https://example.com/products/pixel", //$product_url OPTIONAL
   "image_url" => "https://images.example.com/big/300", //$product_image_url OPTIONAL
   "description" => "This is the product description", //$product_description OPTIONAL
   "barcode" => "9876543210987", //$product_barcode OPTIONAL
   "brand" => "Google", //$product_brand OPTIONAL,
   "price" => "799", //$product_price OPTIONAL
));

$result = $rivio->register_post_purchase_email_multiple_product(
    "1492411013331", //$order_id REQUIRED
    "2015-09-28T09:16:16-04:00", //$ordered_date REQUIRED
    "user@example.com", //$customer_email REQUIRED
    "John", //$customer_first_name REQUIRED
    $products
);

?>
<html>
    <head>
        <title>Register Postpurchase Email with muliple products - Rivio PHP SDK example</title>
    </head>
    <body>
        <h1>Rivio Register Postpurchase Email with muliple products</h1>
        <p>result:</p>
        <pre><?php print_r($result);?></pre>
        Check your postpurchase email queue on 
        <a href="http://dashboard.getrivio.com/dashboard/email/summary" target="_blank">Rivio Dashboard</a>.
        If the "Email status" is "Pending" then the test was successful.
    </body>
</html>

更多示例请上传项目到您的存储,并查看 examples/index.php。