gregoriopellegrino/php-cantook

PHP 对 Cantook (以及 Edigita) API 的包装,用于电子书销售

dev-master 2015-10-07 17:59 UTC

This package is not auto-updated.

Last update: 2024-09-28 17:12:33 UTC


README

A PHP wrapper for Cantook (and Edigita) API for ebook sales. API specifications: http://help.cantook.net/support/solutions/articles/4000034849-the-web-services#2

安装

您可以通过 Composer 进行安装。只需在您的 composer.json 文件中添加 "gregoriopellegrino/php-cantook",如下所示。

{
    "require": {
                "gregoriopellegrino/php-cantook": "dev-master"
    }
}

使用方法

您可以在 test/test.php 文件中找到一些代码。

模拟销售

$platform = new Platform("https://edigita.cantook.net", "username", "password", 310, "ita");
$publication = new Publication("9788874028047", "epub", 2.99, "none", "EUR");
$response = $platform->callService("simulation", $publication);

销售

$platform = new Platform("https://edigita.cantook.net", "username", "password", 310, "ita");
$publication = new Publication("9788874028047", "epub", 2.99, "none", "EUR");
$transaction = new Transaction("123456", "123456", "Gregorio Pellegrino");
$transaction->sale_state = "test";
$response = $platform->callService("sale", $publication, $transaction);

下载

$platform = new Platform("https://edigita.cantook.net", "username", "password", 310, "ita");
$publication = new Publication("9788874028047", "epub", 2.99, "none", "EUR");
$transaction = new Transaction("123456", "123456", "Gregorio Pellegrino");
$transaction->sale_state = "test";
$response = $platform->callService("download", $publication, $transaction);

响应结构

array(3) {
  ["url"]=> "https://edigita.cantook.net/api/organisations/..." // the requested url
  ["code"]=> 200												// the response code
  ["response"]=> "success"										// the response message
}