集成coinsecure api时出错.


Integrating coinsecure api give me error..?

我想在我的代码中集成coinsecure api,这是我使用的api的url。

网址:https://github.com/coinsecure/plugins/tree/master/master/php/SwaggerClient-php

安装/集成API有两种方法:

  1. 使用composer
  2. 手动过程

所以我选择了第二个手动流程,所以基于文档信息

  1. 下载所有文件并添加到我的第三部分库文件夹中
  2. 并添加require_ones autoload.php文件

到这一步,它会很好,但问题是现在发生时,我必须使用这个硬币安全执行操作。

假设我想在过去24小时内获得最低的费率,那么下面的代码是由api提供的。

代码:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
$api_instance = new Swagger'Client'Api'ExchangeTradeDataApi();
$accept = "accept_example"; // string | JSON, XML or CSV can be returned (Optional)
try {
    $result = $api_instance->v1exchangemin24Hr($accept);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling ExchangeTradeDataApi->v1exchangemin24Hr: ', $e->getMessage(), PHP_EOL;
}
?>

当我运行这个代码时,它会给我以下错误:

[404]连接到API时出错(https://api.coinsecure.in/v1/exchange/max24Hr)

有人知道为什么它会给我带来错误吗。。?

奇怪的是,在v1之前的URL中有一个额外的/,导致404错误。相反,它应该是https://api.coinsecure.in/v1/exchange/max24Hr

看起来他们的PHP库是硬编码错误的。从他们的github库第76行

 if ($apiClient == null) {
            $apiClient = new ApiClient();
            $apiClient->getConfig()->setHost('https://api.coinsecure.in/');
        }

然后在136 线上再次包含/

$resourcePath = "/v1/exchange/ask/low";

请注意,基本url是如何以/结尾,而路径是以/开头的。你可以自己更改它,它应该会起作用,但我敢打赌图书馆里的其他电话也被搞砸了。也许让他们知道,这样他们就可以纠正图书馆。

位置:plugins/master/php/SwaggerClient php/lib/Api/ExchangeTradeDataApi.php