apancutt/bitstamp-api

Bitstamp API 的 PHP 库。

dev-master / 1.0.x-dev 2016-05-18 13:33 UTC

This package is not auto-updated.

Last update: 2024-09-24 01:30:54 UTC


README

A PHP 实现用于访问 Bitstamp API

警告:Bitstamp API 允许您执行实时交易。此库免费提供,我将努力使其与 API 更新同步。然而,请记住,我将不对此库的完整性和可靠性承担任何责任,也不会对因使用此库而造成的任何损坏或收益损失负责。请自行决定是否使用。

要求

  • PHP >= 5.4
  • ext-curl
  • ext-json (PHP >= 5.5)
  • ext-mcrypt

安装

Composer

将以下依赖项添加到您的 composer.json 文件中

"require": {
    "apancutt/bitstamp-api": "1.0.*"
}

请注意,此库目前正在开发中,因此您还需要添加

"minimum-stability": "dev"

示例用法

<?php
// Path to the autoloader generated by Composer
require_once __DIR__ . "/../vendor/autoload.php";

// The HTTP request client, provided by panadas/module-httpclient
$request = new \Panadas\Module\HttpClient\Request();

/*
// Alternatively, you can provide an instance of Panadas\Module\LoggerAbstract for log messages
$logger = new \Panadas\Module\Logger\Unbuffered();
$request = new \Panadas\Module\HttpClient\Request($logger);
*/

// Your Bitstamp client/customer ID
$client_id = 0;

// You will need to generate API keys with the required access level using your
// account control panel: https://www.bitstamp.net/account/security/api/
$api_secret = "";
$api_key = "";

try {

    $client = new \Bitstamp\Api\Client($request, $client_id, $api_secret, $api_key);

    $balance = new \Bitstamp\Api\Endpoint\Balance($client))->execute();

    echo "You have {$balance->getBtcBalance()}BTC in your account\n";

} catch (\Exception $exception) {

    echo "{$exception->getMessage()} in {$exception->getFile()}:{$exception->getLine()}\n";
    exit(1);

}

有关可用端点的更多信息,请参阅:https://www.bitstamp.net/api/

捐赠

如果您想支持此项目,欢迎您向 3Q4YPjpz7qbhaewdfCzHbry1v47wX5pWiX 发送捐赠 - 您的支持和慷慨将非常受欢迎。