dutycalculator/dutycalculator-php-sdk

1.0.0 2014-01-30 14:14 UTC

This package is not auto-updated.

Last update: 2024-09-28 15:39:20 UTC


README

此仓库包含一个开源PHP SDK,允许您从PHP应用程序访问DutyCalculator。SDK需要DutyCalculator API账户(请访问http://www.dutycalculator.com/compare-plans/)。有关DutyCalculator API的完整文档,您可以在此找到

用法

示例是开始的好地方。您至少需要的是

require 'dutycalculator-php-sdk/src/dutycalculator.php';

$client = new DutyCalculator_Client('YOUR_API_KEY');

/*
 * Example of getting available import to countries
 */
$countriesTo = $client->getImportToCountries();
print_r($countriesTo->getAsArray());

客户端类中有所有 API调用 的函数表示。但您也可以使用以下代码进行API调用

try
{
	$countriesFrom = $client->sendRequest('supported-countries/from', array('display_alpha2_code' => true));
}
catch (DutyCalculator_Exception $e)
{
	error_log($e);
	$countriesFrom = null;
}

使用Composer

  • "dutycalculator/dutycalculator-php-sdk": "@stable" 添加到 composer.json 文件的 require 部分中。
  • 运行 composer install
  • 示例将如下所示
$client = new DutyCalculator_Client('YOUR_API_KEY');

/*
 * Example of getting available import to countries
 */
$countriesTo = $client->getImportToCountries();

报告问题/错误

错误