PHP code example of anker1992 / china-stock-data
1. Go to this page and download the library: Download anker1992/china-stock-data library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
anker1992 / china-stock-data example snippets
use Anker1992\ChinaStockData\Sources\SinaStock;
$s = new SinaStock(); // 使用新浪股票数据源
$s->getIndex(); // 获取股指
$s->getInfo('600027'); // 获取股票信息
$s->getInfos(['600027']); // 获取批量股票信息
$s->getKlineImg('600027'); // 获取股票K线图
$s->getKlineImgWeekly('600027'); // 获取股票K线图(周)
$s->getKlineImgMonthly('600027'); // 获取股票K线图(月)
$s->getTrendImg('600027'); // 获取股票分时图
use Anker1992\ChinaStockData\Sources\IfengStock;
$s = new IfengStock(); // 使用凤凰网股票数据源
$s->getIndex(); // 获取股指
$s->getInfo('600027'); // 获取股票信息
$s->getInfos(['600027']); // 获取批量股票信息
$s->getKlineData('600027'); // 获取股票K线数据
$s->getTrendData('600027'); // 获取股票分时数据
$s->getKlineImg('600027'); // 获取股票K线图
$s->getTrendImg('600027'); // 获取股票分时图
$s = new SinaStock();
$data = $s->getInfo('600027'); // 获取股票信息
echo json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);