-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
45cd9e7
commit 46130fa
Showing
3 changed files
with
48 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
<?php | ||
|
||
const MEXC_CONFIG = [ | ||
'MEXC_URL_API' => 'https://api.mexc.com/api/v3', | ||
'MEXC_API_ACCESS_KEY' => 'mx0vglDTfAPSDCof1m', | ||
'MEXC_API_SECRET' => '7cf68dd323074ba3b21554091290b607' | ||
'MEXC_URL_API' => 'https://api.mexc.com/api/v3', | ||
'MEXC_API_ACCESS_KEY' => 'mx0vgleBCS3z3msSyq', | ||
'MEXC_API_SECRET' => 'f7d42e5beb7948e083b3d44d2beb4876' | ||
]; | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
use WilianMaique\Mexc\Mexc\Account; | ||
use WilianMaique\Mexc\Mexc\ExchangeInfo; | ||
use WilianMaique\Mexc\Mexc\InfoToken; | ||
use WilianMaique\Mexc\Mexc\PriceTicker; | ||
|
||
dd([ | ||
'InfoToken' => InfoToken::get('WEMIX'), | ||
'Account' => Account::get(), | ||
'PriceTicker' => PriceTicker::get(), | ||
]); | ||
'ExchangeInfo' => ExchangeInfo::get(['MXUSDT', 'BTCUSDT']), | ||
'InfoToken' => InfoToken::get('WEMIX'), | ||
'Account' => Account::get(), | ||
'PriceTicker' => PriceTicker::get('WEMIXUSDT'), | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace WilianMaique\Mexc\Mexc; | ||
|
||
class ExchangeInfo | ||
{ | ||
/* | ||
* | ||
* get current exchange trading rules and symbol information, symbol by name or null to get all list | ||
* https://mexcdevelop.github.io/apidocs/spot_v3_en/#exchange-information | ||
*/ | ||
public static function get(?array $symbols = ['MXUSDT']): array|bool | ||
{ | ||
if (!empty($symbols)) { | ||
$upperCaseSymbols = array_map('strtoupper', $symbols); | ||
$symbols = implode(',', $upperCaseSymbols); | ||
} else $symbols = ''; | ||
|
||
$url = MEXC_CONFIG['MEXC_URL_API'] . '/exchangeInfo?symbols=' . $symbols; | ||
$ch = curl_init($url); | ||
|
||
curl_setopt_array($ch, [ | ||
CURLOPT_CUSTOMREQUEST => 'GET', | ||
CURLOPT_RETURNTRANSFER => true, | ||
CURLOPT_SSL_VERIFYPEER => true, | ||
]); | ||
|
||
$res = curl_exec($ch); | ||
|
||
if (!$res) { | ||
curl_close($ch); | ||
return false; | ||
} | ||
|
||
curl_close($ch); | ||
|
||
return json_decode($res, true); | ||
} | ||
} |