4

I want to integrate coinsecure api in my code, Here is the url for api which I have used.

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

Where there are two method to install/integrate API :

  1. Using composer.
  2. Manual process.

So I have select second one manual Process so based on document information

  1. Download all file and add into my third part library folder.
  2. And add require_ones autoload.php file.

Up to this step it'll fine but problem is now occur when I have perform action using this coin secure.

Suppose I want to get lowest rate over the last 24 hours so for that one bellow code is provided by api.

Code :

<?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;
}
?>

And when I run this code it'll give me error as below :

[404] Error connecting to the API (https://api.coinsecure.in/v1/exchange/max24Hr)

Can any one have idea why it give me error..?

1
  • Did you include your API keys anywhere? I've never used coinsecure but it looks like you need to include authorization headers with your request.
    – m1xolyd1an
    Jul 29, 2016 at 0:53

1 Answer 1

0

Strange, there's an extra / in your URL before the v1 causing a 404 error. Instead it should be https://api.coinsecure.in/v1/exchange/max24Hr

Looks like their PHP library is hard coded wrong. From their github library line 76

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

Then they include the / again on line 136

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

Notice how the base url ends with a / and the path starts with a /. You can change it yourself and it should work, but I bet the other calls in the library are messed up too. Maybe let them know so they can correct the library.

Location: plugins/master/php/SwaggerClient-php/lib/Api/ExchangeTradeDataApi.php

3
  • Thank for pointing me but that I had already triy but it'll give me same error Jul 29, 2016 at 4:30
  • It still says 404 error can't connect to (api.coinsecure.in//v1/exchange/max24Hr)? If there's 2 slashes before v1 then you are still going to get a 404. I'm able to pull the JSON fine when hitting this URL api.coinsecure.in/v1/exchange/max24Hr
    – m1xolyd1an
    Jul 29, 2016 at 4:53
  • Yes I got it your point, Also remove that '//' from that url but it still giving me same error with single '/' in url Jul 29, 2016 at 4:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.