cointokenhub/cmc-api-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cointokenhub/cmc-api-php

Composer 安装命令:

composer require cointokenhub/cmc-api-php

包简介

cmc-api-php is an API Wrapper for the coinmarketcap API

README 文档

README

codecov Build Status

This php package is a wrapper for the coinmarketcap.com API. It supports three endpoints:

  • The ticker endpoint "/ticker", which returns all crypto currencies, and their vital statistics like price, volume, market cap and percentage changes
  • The currency ticker endpoint "/ticker/", which returns all the data in the previous endpoint, except for only the specified coin.
  • The global data endpoint "/global", which returns some stats like the total market cap, active currencies, active markets and so on.

Install

composer require cointokenhub/cmc-api-php

Usage

In a PHP app:

use GuzzleHttp\Client;
use CoinTokenHub\CoinMarketCapApi\CoinMarketCap;

$httpClient = new Client();
$cmcApi = new CoinMarketCap($httpClient);


$api->ticker('AUD', false, 5);
$api->currencyTicker($coin);
$api->globalData();

In Laravel:

Add a route to routes/web.php that looks like below:

Route::get('coin/{coin}', 'CoinController@coin');
Route::get('ticker', 'CoinController@ticker');
Route::get('global_data', 'CoinController@globalData');

Controller looks like below:

<?php

namespace App\Http\Controllers;

use GuzzleHttp\Client;
use CoinTokenHub\CoinMarketCapApi\CoinMarketCap;

class CoinController extends Controller
{
	private $httpClient;

	public function __construct(Client $httpClient) {
		$this->httpClient = $httpClient;
	}

    public function coin($coin) {
		$api = new CoinMarketCap($this->httpClient);
		return json_encode($api->currencyTicker($coin));
    }

    public function ticker() {
	    $api = new CoinMarketCap($this->httpClient);
	    return json_encode($api->ticker('AUD', false, 5));
    }

    public function globalData() {
	    $api = new CoinMarketCap($this->httpClient);
	    return json_encode($api->globalData());
    }
}

Configuring for Laravel

Laravel 5.5 and higher

You don't need to change or add any config as this package uses Package Auto Discovery.

Laravel 5.4 and lower

After installing, register the CoinTokenHub\CoinMarketCapApi\CoinMarketCapServiceProvider service provider in your config/app.php file.

'providers' => [
    // Other service providers...

    CoinTokenHub\CoinMarketCapApi\CoinMarketCapServiceProvider::class,
],

Also add the facade to your aliases array in the config/app.php file in order to easily access this wrapper using the CoinMarketCap alias

'CoinMarketCap' => CoinTokenHub\CoinMarketCapApi\CoinMarketCapFacade::class,

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-04-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固