-
Notifications
You must be signed in to change notification settings - Fork 0
/
get.php
76 lines (33 loc) · 1.73 KB
/
get.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
require_once("api.class.php");
$coinMarketCapApiClass = new coinMarketCapApi;
$coinData = json_decode($coinMarketCapApiClass->getData());
// $coinData->data["tags"] = array(); clear coin tags
if($coinData->status->error_code != 0) die($coinData->status->error_message);
foreach ($coinData->data as $value) {
if(empty($value->id)) continue;
$logo = ""; $grafik = "";
$symbol = $value->symbol;
if(!empty($value->id)) $logo = '<img src="https://s2.coinmarketcap.com/static/img/coins/64x64/'.$value->id.'.png" height="25" width="25" > '; //coin resmini uzak sunucudan getiriyorum.
if(!empty($value->id)) $grafik = '<img src="https://s3.coinmarketcap.com/generated/sparklines/web/7d/2781/'.$value->id.'.svg" height="40" width="120" > '; //get coin grafik
$coinName = $value->name;
$apiMoneyCall = $value->quote->USD; //
if(substr($apiMoneyCall->price,0,1) == 0) $price =number_format($apiMoneyCall->price,4); //if price is 0
else $price= number_format($apiMoneyCall->price,2); //if price not 0
$volume_24h = $apiMoneyCall->volume_24h;
$percent_change_24h = number_format($apiMoneyCall->percent_change_24h,8);
$percent_change_7d = number_format($apiMoneyCall->percent_change_7d,8);
$percent_change_30d = number_format($apiMoneyCall->percent_change_30d,8);
$jsonArray["data"][] = array(
'cift'=>' '.$logo.' '.$symbol.' ',
'coin'=>$coinName,
'price'=>$price,
'percentChange24H'=>'<b class="'.$percent_change_24h_Class.'">'.$percent_change_24h.'</b>',
'percentChange7D'=>$percent_change_7d,
'percentChange30D'=> $percent_change_30d,
'volume24H'=>$volume_24h,
'grafik'=> $grafik
);
}
echo json_encode($jsonArray);
?>