Skip to content

Commit 46130fa

Browse files
committed
ExchangeInfo added
1 parent 45cd9e7 commit 46130fa

File tree

3 files changed

+48
-12
lines changed

3 files changed

+48
-12
lines changed

README.md

-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
# DISCORD
2-
```shell
3-
wilianmaique
4-
```
5-
61
# MEXC-API PHP
72
lib mexc api simple, for detail account, balance spot, withdraw
83
info token, etc...

examples/index.php

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
<?php
22

33
const MEXC_CONFIG = [
4-
'MEXC_URL_API' => 'https://api.mexc.com/api/v3',
5-
'MEXC_API_ACCESS_KEY' => 'mx0vglDTfAPSDCof1m',
6-
'MEXC_API_SECRET' => '7cf68dd323074ba3b21554091290b607'
4+
'MEXC_URL_API' => 'https://api.mexc.com/api/v3',
5+
'MEXC_API_ACCESS_KEY' => 'mx0vgleBCS3z3msSyq',
6+
'MEXC_API_SECRET' => 'f7d42e5beb7948e083b3d44d2beb4876'
77
];
88

99
require __DIR__ . '/../vendor/autoload.php';
1010

1111
use WilianMaique\Mexc\Mexc\Account;
12+
use WilianMaique\Mexc\Mexc\ExchangeInfo;
1213
use WilianMaique\Mexc\Mexc\InfoToken;
1314
use WilianMaique\Mexc\Mexc\PriceTicker;
1415

1516
dd([
16-
'InfoToken' => InfoToken::get('WEMIX'),
17-
'Account' => Account::get(),
18-
'PriceTicker' => PriceTicker::get(),
19-
]);
17+
'ExchangeInfo' => ExchangeInfo::get(['MXUSDT', 'BTCUSDT']),
18+
'InfoToken' => InfoToken::get('WEMIX'),
19+
'Account' => Account::get(),
20+
'PriceTicker' => PriceTicker::get('WEMIXUSDT'),
21+
]);

src/Mexc/ExchangeInfo.php

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace WilianMaique\Mexc\Mexc;
4+
5+
class ExchangeInfo
6+
{
7+
/*
8+
*
9+
* get current exchange trading rules and symbol information, symbol by name or null to get all list
10+
* https://mexcdevelop.github.io/apidocs/spot_v3_en/#exchange-information
11+
*/
12+
public static function get(?array $symbols = ['MXUSDT']): array|bool
13+
{
14+
if (!empty($symbols)) {
15+
$upperCaseSymbols = array_map('strtoupper', $symbols);
16+
$symbols = implode(',', $upperCaseSymbols);
17+
} else $symbols = '';
18+
19+
$url = MEXC_CONFIG['MEXC_URL_API'] . '/exchangeInfo?symbols=' . $symbols;
20+
$ch = curl_init($url);
21+
22+
curl_setopt_array($ch, [
23+
CURLOPT_CUSTOMREQUEST => 'GET',
24+
CURLOPT_RETURNTRANSFER => true,
25+
CURLOPT_SSL_VERIFYPEER => true,
26+
]);
27+
28+
$res = curl_exec($ch);
29+
30+
if (!$res) {
31+
curl_close($ch);
32+
return false;
33+
}
34+
35+
curl_close($ch);
36+
37+
return json_decode($res, true);
38+
}
39+
}

0 commit comments

Comments
 (0)