lightfly / finance
China finance package for php
0.2.4
2020-05-31 04:39 UTC
Requires
- php: ^7.1
- ext-json: *
- ext-openssl: *
- masterminds/html5: ^2.6
- nikic/iter: ^2.0
- phpoffice/phpspreadsheet: ^1.12
- symfony/css-selector: ^4.4
- symfony/dom-crawler: ^4.4
Requires (Dev)
- guzzlehttp/guzzle: ^6.3
- phpspec/phpspec: ^6.1
Suggests
- guzzlehttp/guzzle: ^6.3
README
金融数据服务
安装
composer require guzzlehttp/guzzle
composer require lightfly/finance
使用
基本使用
<?php use GuzzleHttp\Client; use Lightfly\Finance\HttpClient; use Lightfly\Finance\Stock\Stock; $httpClient = new HttpClient(new Client()); $stock = new Stock($httpClient); $data = $stock->HS300(); var_dump($data);
高级
如果不喜欢 guzzle 或者主机配置的原因,可以替换 http client 的实现,只要继承 HttpClientInterface 实现相应的 get 和 post 方法即可,示例:
class AnotherHttpClient implements HttpClientInterface { public function get($url, $options = []) { return file_get_contents($url); } } $httpClient = new AnotherHttpClient(); $stock = new Stock($httpClient); $data = $stock->HS300(); var_dump($data);
Run tests
bin/phpspec run