php-core / changelly-fiat
dev-master
2023-08-13 11:53 UTC
Requires
- ext-openssl: *
- defuse/php-encryption: ^2.3
- guzzlehttp/guzzle: ^7.7
- isecpay/crypto-exchange: dev-master
This package is not auto-updated.
Last update: 2024-12-16 16:51:27 UTC
README
Changelly.com PHP SDK
This library requires min. PHP 8.0
Installation
composer require php-core/changelly-fiat
Examples
Get number
// require_once './vendor/autoload.php';
Authentication
Option 1
Have $_ENV['CHANGELLY_PUBLIC_KEY'] and $_ENV['CHANGELLY_PRIVATE_KEY'] set to the actual keys
Option 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);
Usage
$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";
}
Other examples can be found here
For more, visit the Official changelly Fiat API Documentation
License
This project is licensed under the MIT License.