@@ -26,7 +26,7 @@ public static function get(string $tokenCoinName = null): array|bool
26
26
'X-MEXC-APIKEY: ' . MEXC_CONFIG ['MEXC_API_ACCESS_KEY ' ] . ''
27
27
],
28
28
CURLOPT_RETURNTRANSFER => true ,
29
- CURLOPT_SSL_VERIFYPEER => false ,
29
+ CURLOPT_SSL_VERIFYPEER => true ,
30
30
]);
31
31
32
32
$ res = curl_exec ($ ch );
@@ -40,41 +40,14 @@ public static function get(string $tokenCoinName = null): array|bool
40
40
$ resJson = json_decode ($ res , true );
41
41
curl_close ($ ch );
42
42
43
- if ($ status_code != 200 )
44
- return $ resJson ;
45
-
46
- if (empty ($ tokenCoinName ))
43
+ if ($ status_code != 200 || empty ($ tokenCoinName ))
47
44
return $ resJson ;
48
45
49
46
$ info = [];
50
47
51
48
foreach ($ resJson as $ resJsonValue ) {
52
49
if ($ resJsonValue ['coin ' ] === $ tokenCoinName ) {
53
- $ info ['coin ' ] = $ tokenCoinName ;
54
- $ info ['name ' ] = $ resJsonValue ['name ' ];
55
-
56
- foreach ($ resJsonValue ['networkList ' ] as $ key => $ value ) {
57
- $ info ['networkList ' ][$ key ]['coin ' ] = $ value ['coin ' ];
58
- $ info ['networkList ' ][$ key ]['depositDesc ' ] = $ value ['depositDesc ' ];
59
- $ info ['networkList ' ][$ key ]['depositEnable ' ] = $ value ['depositEnable ' ];
60
- $ info ['networkList ' ][$ key ]['minConfirm ' ] = $ value ['minConfirm ' ];
61
- $ info ['networkList ' ][$ key ]['name ' ] = $ value ['name ' ];
62
- $ info ['networkList ' ][$ key ]['network ' ] = $ value ['network ' ];
63
- $ info ['networkList ' ][$ key ]['withdrawEnable ' ] = $ value ['withdrawEnable ' ];
64
- $ info ['networkList ' ][$ key ]['withdrawFee ' ] = $ value ['withdrawFee ' ];
65
- $ info ['networkList ' ][$ key ]['withdrawIntegerMultiple ' ] = $ value ['withdrawIntegerMultiple ' ];
66
- $ info ['networkList ' ][$ key ]['withdrawMax ' ] = $ value ['withdrawMax ' ];
67
- $ info ['networkList ' ][$ key ]['withdrawMin ' ] = $ value ['withdrawMin ' ];
68
- $ info ['networkList ' ][$ key ]['sameAddress ' ] = $ value ['sameAddress ' ];
69
- $ info ['networkList ' ][$ key ]['contract ' ] = $ value ['contract ' ];
70
- $ info ['networkList ' ][$ key ]['withdrawTips ' ] = $ value ['withdrawTips ' ];
71
- $ info ['networkList ' ][$ key ]['depositTips ' ] = $ value ['depositTips ' ];
72
- }
73
-
74
- if (count ($ resJsonValue ['networkList ' ]) <= 0 )
75
- reset ($ info ['networkList ' ]);
76
-
77
- break ;
50
+ return self ::transformInfo ($ resJsonValue );
78
51
}
79
52
}
80
53
@@ -83,4 +56,44 @@ public static function get(string $tokenCoinName = null): array|bool
83
56
84
57
return $ info ;
85
58
}
59
+
60
+ /*
61
+ *
62
+ * transform array info
63
+ */
64
+ private static function transformInfo (array $ resJsonValue ): array
65
+ {
66
+ $ info = [
67
+ 'msg ' => 'ok ' ,
68
+ 'coin ' => $ resJsonValue ['coin ' ],
69
+ 'name ' => $ resJsonValue ['name ' ],
70
+ 'networkList ' => [],
71
+ ];
72
+
73
+ foreach ($ resJsonValue ['networkList ' ] as $ value ) {
74
+ $ info ['networkList ' ][] = [
75
+ 'coin ' => $ value ['coin ' ],
76
+ 'depositDesc ' => $ value ['depositDesc ' ],
77
+ 'depositEnable ' => $ value ['depositEnable ' ],
78
+ 'minConfirm ' => $ value ['minConfirm ' ],
79
+ 'name ' => $ value ['name ' ],
80
+ 'network ' => $ value ['network ' ],
81
+ 'withdrawEnable ' => $ value ['withdrawEnable ' ],
82
+ 'withdrawFee ' => $ value ['withdrawFee ' ],
83
+ 'withdrawIntegerMultiple ' => $ value ['withdrawIntegerMultiple ' ],
84
+ 'withdrawMax ' => $ value ['withdrawMax ' ],
85
+ 'withdrawMin ' => $ value ['withdrawMin ' ],
86
+ 'sameAddress ' => $ value ['sameAddress ' ],
87
+ 'contract ' => $ value ['contract ' ],
88
+ 'withdrawTips ' => $ value ['withdrawTips ' ],
89
+ 'depositTips ' => $ value ['depositTips ' ],
90
+ ];
91
+ }
92
+
93
+ if (count ($ resJsonValue ['networkList ' ]) <= 0 ) {
94
+ reset ($ info ['networkList ' ]);
95
+ }
96
+
97
+ return $ info ;
98
+ }
86
99
}
0 commit comments