【问题标题】:Check Bitcoin Balance with mybitx api https GET url使用 mybitx api https GET url 检查比特币余额
【发布时间】:2018-02-13 21:41:36
【问题描述】:

我刚开始将比特币 API 集成到我的 PHP 页面,我已经使用 luno 创建了一个比特币帐户,我已经创建了 API 密钥。

我已获得此 url 以使用我生成的 API 密钥获得平衡:

$ curl -u keyid:keysecret https://api.mybitx.com/api/1/balance

谁能提供一个合适的例子来说明我如何使用我的 API 和这个给定的 url 在 PHP 页面上显示我的钱包余额?

【问题讨论】:

    标签: php api bitcoin


    【解决方案1】:

    我知道将curl 命令转换为可执行PHP 代码的最简单方法是使用此站点:https://incarnate.github.io/curl-to-php/

    只需添加您的curl 命令:

    curl -u keyid:keysecret https://api.mybitx.com/api/1/balance
    

    到显示“在此处粘贴 curl”的文本框。然后获取输出的 PHP 并将其集成到您的应用程序中。

    【讨论】:

    • 这工作得很好,虽然我没有使用表单中的实际密钥,但我在复制完成的 php.ini 时添加了它。谢谢
    【解决方案2】:

    您可以使用PHP Requests library 轻松地发出 HTTP 请求。您的curl 命令可以转换如下:

    <?php
        include('vendor/rmccue/requests/library/Requests.php');
        Requests::register_autoloader();
        // Use additional headers if necessary
        $headers = array();
        // Create authorization using key and secret.
        $options = array('auth' => array('keyid', 'keysecret'));
        // Create the GET request to the URL
        $response = Requests::get('https://api.mybitx.com/api/1/balance', $headers, $options);
        // The result is available in $response
    ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-12
      • 2013-12-27
      • 1970-01-01
      • 1970-01-01
      • 2015-06-14
      • 2021-01-06
      • 2021-05-19
      • 1970-01-01
      相关资源
      最近更新 更多