php-core/changelly-fiat

dev-master 2023-08-13 11:53 UTC

This package is not auto-updated.

Last update: 2024-09-23 15:36:07 UTC


README

Changelly.com PHP SDK

此库需要最小 PHP 8.0

安装

composer require php-core/changelly-fiat

示例

获取数字

// require_once './vendor/autoload.php';

身份验证

选项 1

设置 $_ENV['CHANGELLY_PUBLIC_KEY'] 和 $_ENV['CHANGELLY_PRIVATE_KEY'] 为实际密钥

选项 2

// Replace 'YOUR_PUBLIC_KEY' with your actual API key from Changelly.
$publicKey = 'YOUR_PUBLIC_KEY';

// Replace PATH_TO_PRIVATE_KEY with the actual full path to a file storing your private key from Changelly. 
$privateKey = '/full/path/to/private.key';

PHPCore\Changelly\Fiat\Api::init($publicKey, $privateKey);

使用


$fiat = 'USD';
$crypto = 'BTC';
$amount = 50;
$countryCode = 'EE';
$stateCode = ''; // use US state code if country code is US
$userId = '567890';
$ipAddress = 'USER_IP'; // replace with user IP address

try {
	// Example: Getting a number for a specific service and country.
    $offers = PHPCore\Changelly\Fiat\Api::getOffers(
        $fiat, $crypto,
	    $amount, $countryCode, null,
		$userId, $stateCode, $ipAddress
    );	
        
    print_r($offers);
       
} catch (Exception $e) {
	echo "Error: " . $e->getMessage() . "\n";
}

其他示例可以在这里找到

更多信息,请访问官方 Changelly Fiat API 文档

许可证

本项目遵循 MIT 许可证。